Total members 11890 |It is currently Fri Apr 26, 2024 2:58 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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     -  
 Lines on the plane     -  
 Drawing Lines in php     -  
 Script ingoring lines     -  
 Draw Triangle using Lines     -  
 increase the number of bank lines by <br/>     -  
 draw any number of lines on mouse clicks     -  



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
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com