2012年10月2日 星期二

week04,hw04

void setup()
{
size(500,400);
background(255);
fill(255,0,0);rect(0,0,50,50);
fill(255,128,50);rect(0,50,50,50);
fill(255,255,0);rect(0,100,50,50);
fill(0,255,0);rect(0,150,50,50);
fill(0,0,255);rect(0,200,50,50);
fill(0,0,0);rect(0,250,50,50);
//------------------------------//fill(255);
rect(450,0,50,50);
ellipse(475, 25, 3,3);
rect(450,50,50,50);
ellipse(475, 75, 6, 6);
rect(450,100,50,50);
ellipse(475, 125, 10,10);

strokeWeight(1);
}
void draw()
{
if(mouseX&rt;450 && mouseX<500 && mouseY&rt;0 && mouseY<50 && mousePressed)
{
strokeWeight(3);
}
else if(mouseX&rt;450 && mouseX<500 && mouseY&rt;50 && mouseY<100 && mousePressed)
{
strokeWeight(6);
}
else if(mouseX&rt;450 && mouseX<500 && mouseY&rt;100 && mouseY<150 && mousePressed)
{
strokeWeight(10);
}
//==========================//else if(mouseX < 50 && mouseY<50 && mousePressed)
{
stroke(255,0,0);
}
else if(mouseX < 50 && mouseY<100 && mousePressed)
{
stroke(255,128,50);
}
else if(mouseX < 50 && mouseY<150 && mousePressed)
{
stroke(255,255,0);
}
else if(mouseX < 50 && mouseY<200 && mousePressed)
{
stroke(0,255,0);
}
else if(mouseX < 50 && mouseY<250 && mousePressed)
{
stroke(0,0,255);
}
else if(mouseX < 50 && mouseY<300 && mousePressed)
{
stroke(0,0,0);
}
else if(mousePressed)
{
line(mouseX,mouseY,pmouseX,pmouseY);
}
}

1 則留言: