void setup()
{
background(55,155,25);
size(500,400);
stroke(0,0,0);
strokeWeight(1);
fill(255,0,0);
rect(0,0,50,50);
fill(0,255,0);
rect(0,50,50,50);
fill(0,0,255);
rect(0,100,50,50);
fill(0,0,0);
rect(0,150,50,50);
fill(255,255,255);
rect(0,200,50,50);
rect(450,0,50,50);
fill(0,0,0);
text("eraser", 460,30);
fill(255, 255, 255);
rect(450,50,50,50);
ellipse(475,75,1,1);
rect(450,100,50,50);
ellipse(475,125,5,5);
rect(450,150,50,50);
ellipse(475,175,10,10);
rect(450,200,50,50);
fill(0,0,0);
text("Clear", 460,230);
fill(255,255,255);
rect(450,250,50,50);
fill(0,0,0);
text("Save", 460,280);
}
void draw()
{
if(mouseX<50 && mouseY <50 && mousePressed)
{
stroke(255,0,0);
}
else if(mouseX<50 && mouseY <100 && mousePressed)
{
stroke(0,255,0);
}
else if(mouseX<50 && mouseY <150 && mousePressed)
{
stroke(0,0,255);
}
else if(mouseX<50 && mouseY <200 && mousePressed)
{
stroke(0,0,0);
}
else if(mouseX<50 && mouseY <250 && mousePressed)
{
stroke(255,255,255);
}
else if(mouseX>450 && mouseY <50 && mousePressed)
{
stroke(255,255,255);
}
else if(mouseX>450 && mouseY <100 && mousePressed)
{
strokeWeight(1);
}
else if(mouseX>450 && mouseY <150 && mousePressed)
{
strokeWeight(5);
}
else if(mouseX>450 && mouseY <200 && mousePressed)
{
strokeWeight(10);
}
else if(mouseX>450 && mouseY <250 && mousePressed)
{
setup();
}
else if(mouseX>450 && mouseY <300 && mousePressed)
{
save("1.jpg");
}
else if(mousePressed)
{
line(mouseX,mouseY,pmouseX,pmouseY);
}
}
2.心得
這次的還蠻有趣的,用自己設計的小畫家畫圖,超有成就感,感覺自己好像有點樣子了
好像很厲害一樣,期待下周的課程,能學到更多更精彩的東西!
95
回覆刪除