วันจันทร์ที่ 1 กันยายน พ.ศ. 2557
EX 1 : Task#2 - Quadrant Check
void setup(){
background(255);
size(500,500);
textAlign(CENTER);
}
void draw()
{
background(255);
fill(255);
strokeWeight(8);
rect(0,0,width,height);
strokeWeight(5);
line(0,height/2, width,height/2);
line(width/2,0, width/2, height);
if(mouseX > width/2 && mouseY < height/2)
{fill(150);rect(width/2,0,width/2,height/2);fill(0);text("Quadrant 1", width*3/4,height/4);}
else if(mouseX < width/2 && mouseY < height/2)
{fill(150);rect(0,0,width/2,height/2);fill(0);text("Quadrant 2",width*1/4,height/4);}
else if(mouseX < width/2 && mouseY > height/2)
{fill(150);rect(0,height/2,width/2,height/2);fill(0);text("Quadrant 3",width*1/4,height*3/4);}
else
{fill(150);rect(width/2,height/2,width/2,height/2);fill(0);text("Quadrant 4",width*3/4,height*3/4);}
}
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น