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.