程式碼:
void setup() {
background(255,255,255);
size(500, 400);
fill(0,0,0);
rect(0, 0, 50, 50);
fill(255,0,0);
rect(0, 50, 50, 50);
fill(0,0,255);
rect(0, 100, 50, 50);
fill(0,255,0);
rect(0, 150, 50, 50);
fill(128,0,255);
rect(0, 200, 50, 50);
fill(255,255,255);
rect(450, 0, 50, 50);
fill(255,255,255);
rect(450, 50, 50, 50);
fill(255,255,255);
rect(450, 100, 50, 50);
fill(255,255,255);
rect(450, 150, 50, 50);
fill(255,255,255);
rect(450, 200, 50, 50);
PFont font;
font = loadFont("Univers-66.vlw");
textFont(font);
textSize(15);
fill(0);
text("clear", 460, 30);
text("save", 460, 80);
text("Eraser", 450, 140);
textSize(100);
text(" . ", 430, 180);
textSize(30);
text(" . ", 460, 230);
smooth();
}
void draw() {
fill(0,0,0);
if (mousePressed == true) {
if (mouseButton == LEFT) {
if(mouseX>0 && mouseX<50 && mouseY>0 && mouseY<50)stroke(0,0,0);
if(mouseX>0 && mouseX<50 && mouseY>50 && mouseY<100)stroke(255,0,0);
if(mouseX>0 && mouseX<50 && mouseY>100 && mouseY<150)stroke(0,0,255);
if(mouseX>0 && mouseX<50 && mouseY>150 && mouseY<200)stroke(0,255,0);
if(mouseX>0 && mouseX<50 && mouseY>200 && mouseY<300)stroke(128,0,255);
if(mouseX>450 && mouseX<500 && mouseY>0 && mouseY<50) {
noStroke();
fill(255,255,255);
rect(51,0,399,500) ;
}
if(mouseX>450 && mouseX<500 && mouseY>50 && mouseY<100)save("00360940.gif");
if(mouseX>450 && mouseX<500 && mouseY>100 && mouseY<150)stroke(255,255,255);
if(mouseX>450 && mouseX<500 && mouseY>150 && mouseY<200)strokeWeight(20);
if(mouseX>450 && mouseX<500 && mouseY>200 && mouseY<250)strokeWeight(5);
if(mouseX>50 && mouseX<450 && mouseY>0 && mouseY<400)line(mouseX, mouseY, pmouseX, pmouseY);
}
}
}
心得:
今天對小畫家的功能又更進一步的了解了,也了解了clear的更進一步的用法,
只要設長方形的範圍用fill和原本背景的顏色一樣,那這樣就可以達到clear的效果了
下禮拜還有很多的課程等著我去學習。

沒有留言:
張貼留言