1,小畫家
void setup()
{
background(255);
size(600,600);
fill(255,0,0,60); //red
noStroke();
rect(0,0,50,50);
fill(255,255,0,60); //yellow
noStroke();
rect(0,50,50,50);
fill(0,0,255,60); //blue
noStroke();
rect(0,100,50,50);
fill(0,255,0,60); //green
noStroke();
rect(0,150,50,50);
fill(0,0,0,80); //black
noStroke();
rect(0,200,50,50);
fill(255,255,255); //thin
stroke(200);
rect(0,250,50,50);
fill(0,0,0);
ellipse(0+25,250+25,5,5);
fill(255,255,255); //stok
stroke(200);
rect(0,300,50,50);
fill(0,0,0);
ellipse(0+25,300+25,10,10);
fill(255,255,255); //eraser
stroke(200);
rect(0,350,50,50);
fill(255);
rect(0+20,350+20,10,10);
stroke(0,0,0);
strokeWeight(2);
fill(255,255,255); //save
stroke(100);
rect(0,400,50,50);
fill(255);
scale(0.5);
triangle(25,820,53,875,81,820);
}
void draw()
{
if(mouseX <50 && mouseY >450 && mouseY <500 && mousePressed)
{
save("aaa.png");
}
else if(mouseX <50 && mouseY >350 && mouseY <400 && mousePressed)
{
stroke(255);
}
else if(mouseX <50 && mouseY >250 && mouseY <300 && mousePressed)
{
strokeWeight(3);
}
else if(mouseX <50 && mouseY >300 && mouseY <350 && mousePressed)
{
strokeWeight(10);
}
else if(mouseX <50 && mouseY <50 && mousePressed)
{
stroke(255,0,0);
}
else if(mouseX <50 && mouseY <100 && mousePressed)
{
stroke(255,255,0);
}
else if(mouseX <50 && mouseY <150 && mousePressed)
{
stroke(0,0,255);
}
else if(mouseX <50 && mouseY <200 && mousePressed)
{
stroke(0,255,0);
}
else if(mouseX <50 && mouseY <250 && mousePressed)
{
stroke(0,0,0);
}
else if(mousePressed)
{
line(mouseX,mouseY,pmouseX,pmouseY);
}
}
2.本周心得
今天我參考去年學長姊的小畫家
了解了其中程式的涵義
並且更改了畫筆顏色
加入調整大小以及存檔的動作
另外我把調色盤介面,調成半透明狀態
讓介面變得有質感,這個idear是 從win7視窗想到的
這樣讓小畫家介面變得比較柔和舒適
當然最主要學到的技巧還是在滑鼠行為上面
因為小畫家,讓滑鼠控制的技巧越來越純熟
98
回覆刪除