Mon May 07, 2007 11:19 pm
/**
*
*/
class myCanvas extends Canvas
{
public myCanvas(int x1,int y1,int R)
{
this.x1=x1;
this.y1=y1;
this.R=R;
}
protected void paint(Graphics g)
{
g.fillRect(0,0,300,300);
g.setColor(200,23,43);
float p=1-R;
float theta=0.0f;
int x=0;
int y=R;
while(x<=y)
{
if(p<0)
{
x=x+1;
p=p+2*x+1;
}
else if(p>=0)
{
x=x+1;
y=y-1;
p=p+2*x+1-2*y;
}
g.drawLine(x+(100)+x1,(150)-y-y1,x+(100)+x1,(150)-y-y1);
g.drawLine(-x+(100)+x1,(150)-y-y1,-x+(100)+x1,(150)-y-y1);
g.drawLine(x+(100)+x1,(150)+y-y1,x+(100)+x1,(150)+y-y1);
g.drawLine(-x+(100)+x1,(150)+y-y1,-x+(100)+x1,(150)+y-y1);
g.drawLine(y+(100)+x1,(150)-x-y1,y+(100)+x1,(150)-x-y1);
g.drawLine(-y+(100)+x1,(150)-x-y1,-y+(100)+x1,(150)-x-y1);
g.drawLine(y+(100)+x1,(150)+x-y1,y+(100)+x1,(150)+x-y1);
g.drawLine(-y+(100)+x1,(150)+x-y1,-y+(100)+x1,(150)+x-y1);
}
}
int x1=0;
int y1=0;
int R=0;
}
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
Powered by phpBB © phpBB Group.