void setup(){
size(600,600);
}
int d; //diameter of circle
int r; //radiuse of circle
float area; //area of circle
float circleF;//circleF is circleference
void draw(){
background(0);
d=100+mouseX; //set diameter frome mouseX
// set up theory
r=d/2;
area=PI*(r*r);
circleF=2*PI*r;
//circle picture
stroke(255);
noFill();
ellipse(300,200,r,r);
//line of diameter in x line
stroke(255,0,0);
text("diameter",300+(r/6),195);
line(300+(r/2),200,300-(r/2),200);
//line of radius in Y line
stroke(0,255,0);
line(300,200,300,200+(r/2));
text("radius",310,200+(r/4));
//show value
text("The diameter of this circle is "+d,50,460);
text("The radius of this circle is "+r,50,480);
text("The area of this circle is "+area,50,500);
text("The circleference of this circle is "+circleF,50,520);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น