I was learning about how to save the background in what kind of file and the name of the file , earsing the drown line on the background. It was good for me to obtain the concept in this one.
void setup(){
size(500,400);
strokeWeight(3);
smooth();
background(205);
fill(255,255,255);
rect(55,3,387,380);
fill(255,0,0);
rect(0,0,50,50);
fill(100,0,255);
rect(0,50,50,50);
fill(190,150,200);
rect(0,100,50,50);
fill(160,50,150);
rect(0,150,50,50);
//////////////
fill(255,255,255);
rect(448,0,50,50);
fill(255,255,255);
rect(448,50,50,50);
fill(250,255,255);
rect(448,100,50,50);
fill(255);
rect(448,150,50,50);
fill(0);
ellipse(475,175,2,2);
stroke(0,0,0);
PFont font; // Declare the variable
font = loadFont("AmericanTypewriter-24.vlw"); // Load the font
textFont(font); // Set the current text font
fill(0);
textAlign(CENTER);
textSize(12);
text("Save", 450, 25, 50,50);
textSize(12);
text("Eraser",450, 75,50,50);
textSize(12);
text("Clear",450, 125,50,50);
}
void draw(){
if (mousePressed && mouseX>=0 &&mouseX<=53 &&mouseY>=0 && mouseY<=50)
stroke(255,0,0);
if(mousePressed &&mouseX>=0 && mouseX<=53 &&mouseY>50 && mouseY<=100)
stroke(100 ,0, 255);
if(mousePressed &&mouseX>=0 && mouseX<=53 &&mouseY>100 && mouseY<=150)
stroke(190,150,200);
if(mousePressed &&mouseX>=0 && mouseX<=53 &&mouseY>150 && mouseY<=200)
stroke(160,50,150);
if(mousePressed &&mouseX>=0 && mouseX<=450 &&mouseY>3 && mouseY<=50)
save("line-##.jpg");
if(mousePressed &&mouseX>=450 && mouseX<=500 &&mouseY>=50 && mouseY<=100)
stroke(255);
if(mousePressed &&mouseX>=450 && mouseX<=500 &&mouseY>=100 && mouseY<=150)
setup();
if(mousePressed &&mouseX>=450 && mouseX<=500 &&mouseY>=150 && mouseY<=200)
strokeWeight(2);
if(mousePressed &&( mouseX >=65&&mouseX<=445 ))
line(mouseX, mouseY, pmouseX,pmouseY);
}
沒有留言:
張貼留言