Total members 11366 |It is currently Sat Oct 25, 2014 12:04 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R

All times are UTC [ DST ]



  Sphere by Lines
Sat Apr 07, 2007 8:15 pm 

This a trivial graphics program i made. I draw a sphere using loop to change the degree of the rotation theta.

java code
// LineCircle.java
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;

/**
*

*/
public class LineCircle extends JFrame{

/** Creates a new instance of LineCircle */

private int r=200;
private float theta;
private int width=500;
private int height=500;
private int x=0;
private int y=0;
public LineCircle() {
setTitle("Codemiles");
setSize(width,height);

}
public void paint(Graphics g) {
g.fillRect(0,0,500,500);
g.setColor(Color.RED);
int drawX=0;
int drawY=0;
int color=0;
while(theta<360)
{
g.setColor(new Color(255-color,10+color,color));
drawX=(x+(int)(r*Math.cos(theta)));
drawY=(y+(int)(r*Math.sin(theta)));
g.drawLine(0+250,250-0,drawX+250,250-drawY);
theta+=0.5;
if(theta%2==0)
color++;
}
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
LineCircle LC=new LineCircle();
LC.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
LC.setVisible(true);
}



}


_________________
Recommend my post if you found it helpful.


Last edited by msi_fci on Thu May 03, 2007 11:17 pm, edited 1 time in total.

Author:
Newbie
User avatar Posts: 15
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Sphere by Lines
 drawing a rotating sphere     -  
 Draw a solid sphere using openGL     -  
 Adding lighting to a solid sphere     -  
 rotate sphere in a circle with light     -  
 Drawing Lines in php     -  
 Lines on the plane     -  
 Script ingoring lines     -  
 Draw Triangle using Lines     -  
 increase the number of bank lines by <br/>     -  
 draw any number of lines on mouse clicks     -  

All times are UTC [ DST ]



Topic Tags

Java Graphics






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team