心得:
終於把小畫家完成了!!!加了好多功能超強!!!! 這次學會如何加入文字跟存檔,我還發現利用全域變數可以讓線的粗細慢慢調整,這點我想了很久,但是很值得!
註:
我畫了很久現在已經下課了我還在教室打心得 XD
程式碼:
void setup(){
size(500,400);
background(255);
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);
rect(0, 150, 50, 50);
fill(143);
rect(0,200,50,50);
//-------------------------
fill(255);
rect(450, 0, 50, 50);
fill(255);
rect(450, 50, 50, 50);
fill(255);
rect(450, 100, 50, 50);
fill(255);
rect(450, 150, 50, 50);
fill(255);
rect(450, 200, 50, 50);
//-------------------------
PFont font; // Declare the variable
font = loadFont("Ziggurat-HTF-Black-32.vlw"); // Load the font
textFont(font); // Set the current text font
textSize(11);
fill(150,125,70);
text(" Clear", 450, 30); // Write "LAX" at coordinate (0,40)
text(" Eraser", 450, 80);
text("Widener", 450, 130);
text(" Slimer", 450, 180);
text(" Save", 450, 230);
//-------------------------
strokeWeight(8);
smooth();
}
float i=8;
void draw(){
if (mousePressed == true) {
if(mouseX<=50 && mouseY<=50)
{
stroke(255,0,0);
}
if(mouseX<=50 && mouseY>50&& mouseY<=100)
{
stroke(0,255,0);
}
if(mouseX<=50 && mouseY>100 && mouseY<=150)
{
stroke(0,0,255);
}
if(mouseX<=50 && mouseY>150 && mouseY<=200)
{
stroke(0);
}
if(mouseX<=50 && mouseY>200 && mouseY<=250)
{
stroke(143);
}
//-----------------------------------------
if(mouseX>=450 && mouseY<=50)
{
stroke(0);
strokeWeight(1);
setup();
}
if(mouseX>=450 && mouseY>50 && mouseY<=100)
{
stroke(255);
}
if(mouseX>=450 && mouseY>100 && mouseY<=150)
{
i=i+1;
if(i>0)
strokeWeight(i);
else
strokeWeight(1);
}
if(mouseX>=450 && mouseY>150 && mouseY<=200)
{
i=i-1;
if(i>0)
strokeWeight(i);
else
strokeWeight(1);
}
if(mouseX>=450 && mouseY>200 && mouseY<=250)
{
save("00360612.jpg");
}
//-----------------------------------------
if(!(mouseX<=50+10&&mouseY<=250+10) &&!( mouseX>=450-10 && mouseY<=250+10))
line(mouseX,mouseY,pmouseX,pmouseY);
}
}

沒有留言:
張貼留言