วันอังคารที่ 2 กันยายน พ.ศ. 2557
Lab2 : soccer (football) field
void setup() {
size(323, 200);
background(#2EB82E);
fill(#2EB82E);
strokeWeight(3);
draw_quadInField(25,20,25,180,300,180,300,20);
draw_ellipseInField(162.5,100,40,40);
draw_lineInField(162.5,20,162.5,180);
draw_cornerField(25,180,15);
}
void draw_quadInField(float originalX1,float originalY1,float originalX2,float originalY2,float originalX3,float originalY3,float originalX4,float originalY4){
quad(originalX1,originalY1,originalX2,originalY2,originalX3,originalY3,originalX4,originalY4); //field
quad(originalX1,originalY1+30,originalX2,originalY2-30,originalX3-230,originalY3-30,originalX4-230,originalY4+30); //penalty area (left court)
quad(originalX1,originalY1+50,originalX2,originalY2-50,originalX3-250,originalY3-50,originalX4-250,originalY4+50); //penalty area (left court)
quad(originalX1,originalY1+65,originalX2,originalY2-65,originalX3-285,originalY3-65,originalX4-285,originalY4+65); //goal (left court)
quad(originalX1+275,originalY1+130,originalX2+275,originalY2-130,originalX3-45,originalY3-130,originalX4-45,originalY4+130); //penalty area (right court)
quad(originalX1+275,originalY1+50,originalX2+275,originalY2-50,originalX3-25,originalY3-50,originalX4-25,originalY4+50); //penalty area(right court)
quad(originalX1+275,originalY1+65,originalX2+275,originalY2-65,originalX3+10,originalY3-65,originalX4+10,originalY4+65); //goal (right court)
}
void draw_ellipseInField(float originalX1,float originalY1,float originalWidth,float originalHeight){
ellipse(originalX1,originalY1,originalWidth,originalHeight) ; //center circle
}
void draw_lineInField(float originalX1,float originalY1,float originalX2,float originalY2){
line(originalX1,originalY1,originalX2,originalY2); //half way line
}
void draw_cornerField(float originalX1,float originalY1,float originalRadius){
arc(originalX1,originalY1-160,originalRadius,originalRadius,0,PI/2); //top corner (left court)
arc(originalX1,originalY1,originalRadius,originalRadius,TWO_PI-PI/2,TWO_PI); //buttom corner (left court)
arc(originalX1+275,originalY1-160,originalRadius,originalRadius, PI/2,PI); //top corner (right court)
arc(originalX1+275,originalY1,originalRadius,originalRadius, PI, TWO_PI-PI/2); //buttom corner (right court)
}
ป้ายกำกับ:
Lab2
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น