2012年10月2日 星期二

week4hw4

今天我成功地完成了自己的小畫家 ^__>^ y
可以選顏色,放大縮小筆粗細度,存檔,載檔

void setup(){

background (255,202,202);
size(500,400); //設定視窗大小
fill(247,70,119);
rect(0,0,50,50);
fill(255,255,128);
rect(0,50,50,50);
fill(128,255,128);
rect(0,100,50,50);
fill(149,255,255);
rect(0,150,50,50);
fill(0,128,255);
rect(0,200,50,50);
fill(0,0,0);
rect(0,250,50,50);
fill(255,202,202);
rect(0,300,50,50);
fill(255,202,202);
rect(450,0,50,50);
rect(450,50,50,50);
rect(450,100,50,50);
rect(450,150,50,50);
fill(255,255,255);
rect(465,120,20,20);
}
void draw(){
int www=5;
line(476,163,476,190);
line(480,190,466,183);
line(480,190,490,183);
ellipse(476,24,5,5);
ellipse(476,76,10,10);

if(mousePressed && mouseX<50 && mouseY<50 ) stroke (247,70,119);
else if(mousePressed && mouseX<50 && mouseY<100 ) stroke (255,255,128);
else if(mousePressed && mouseX<50 && mouseY<150 ) stroke (128,255,128);
else if(mousePressed && mouseX<50 && mouseY<200 ) stroke (149,255,255);
else if(mousePressed && mouseX<50 && mouseY<250 ) stroke (0,128,255);
else if(mousePressed && mouseX<50 && mouseY<300 ) stroke (0,0,0);
else if(mousePressed && mouseX<50 && mouseY<350 ) stroke (255,202,202);


else if(mousePressed && mouseX>450 && mouseY<50){
strokeWeight(++www);
}
else if(mousePressed && mouseX>450 && mouseY<100){
strokeWeight(--www);
if(www<2)www=2;
}
else if(mousePressed && mouseX>450 && mouseY<150) save("imageout.png");
else if(mousePressed && mouseX>450 && mouseY<200){
PImage file = loadImage("imageout.png");
image(file,0,0,500,400);
}
else if(mousePressed)line(mouseX,mouseY,pmouseX,pmouseY); //mousePressed 滑鼠按下
}

覺得真開心,剛開始有點小緊張不太會寫,後來參考老師和上屆學長姐的程式碼,完成了我可愛的小畫家,其實蠻簡單的 哈哈 ^__^

1 則留言: