程式碼:
void setup() {
size(800, 800);
background(255);
//設定顏色選取方塊
noStroke();
fill(#FF0900); //顏色用代碼,不受 RGB或 HSB影響
rect(0, 0, 100, 100);
fill(#FF7300);
rect(0, 100, 100, 100);
fill(#FFEA00);
rect(0, 200, 100, 100);
fill(#36FF00);
rect(0, 300, 100, 100);
fill(#00FFE8);
rect(0, 400, 100, 100);
fill(#001BFF);
rect(0, 500, 100, 100);
fill(#8B00FF);
rect(0, 600, 100, 100);
//color Mode調色盤
noStroke(); //去除邊線
colorMode(HSB, 100); // (調色盤模式, 最大值MAX)
for (int i = 0; i < 100; i++) {
for (int j = 700; j < 800; j++) {
stroke(i, j, 100); // (i, j, alpha)
point(i, j);
}
}
//筆粗
stroke(0);
fill(255);
rect(700, 0, 100, 100);
fill(0);
strokeWeight(30);
stroke(0);
point(750, 50);
stroke(0);
strokeWeight(1);
fill(255);
rect(700, 100, 100, 100);
fill(0);
strokeWeight(15);
stroke(0);
point(750, 150);
stroke(0);
strokeWeight(1);
fill(255);
rect(700, 200, 100, 100);
fill(0);
strokeWeight(3);
stroke(0);
point(750, 250);
//存檔
strokeWeight(1);
fill(255);
rect(700, 300, 100, 100);
fill(0);
text("save image", 720, 350);
}
void draw() {
}
void mouseDragged() {
//畫線
if (mouseX>100){
if(mouseX<700 || mouseY>400){
line( mouseX, mouseY, pmouseX, pmouseY );
}
}
}
void mouseClicked() {
//選擇顏色
if (mouseX<100 && mouseY<100) stroke(#FF0900);
else if (mouseX<100 && mouseY<200) stroke(#FF7300);
else if (mouseX<100 && mouseY<300) stroke(#FFEA00);
else if (mouseX<100 && mouseY<400) stroke(#36FF00);
else if (mouseX<100 && mouseY<500) stroke(#00FFE8);
else if (mouseX<100 && mouseY<600) stroke(#001BFF);
else if (mouseX<100 && mouseY<700) stroke(#8B00FF);
else if (mouseX<100 && mouseY<800) stroke(mouseX, mouseY, 100);
//選擇粗細
if (mouseX>700 && mouseY<100) strokeWeight(30);
else if (mouseX>700 && mouseY<200) strokeWeight(15);
else if (mouseX>700 && mouseY<300) strokeWeight(3);
else if (mouseX>700 && mouseY<400) save("practice.png");
}
沒有留言:
張貼留言