wanna
YaBB Newbies
Offline
Posts: 2
Re: simple paint program
Reply #2 - Dec 13th , 2006, 9:51pm
Thanks shiffman, because of that piece of code i was able to complete it. For anyone who is interested, here is my (final) version; //Wanna //code problem solved by shiffman //Paint Prog //Dec 2006 int Yellow; int Red; int Green; int Blue; int Grey; int LightGrey; color currentColor; boolean typeIsRect; void setup() { size(640,480); background(102); frameRate(60); Yellow = color(255,255,0); Red = color(255,0,0); Green = color(0,255,0); Blue = color(0,0,255); Grey = color(102); LightGrey = color(200); currentColor = color(102); typeIsRect = true; } //interface void draw() { stroke(5); smooth(); fill(LightGrey); rect(10,10,190,70); fill(Yellow); rect(20,20,20,20); fill(Red); rect(50,20,20,20); fill(Green); rect(80,20,20,20); fill(Blue); rect(110,20,20,20); fill(Grey); rect(140,20,50,50); //the eraser fill(Yellow); ellipse(30,60,20,20); fill(Red); ellipse(60,60,20,20); fill(Green); ellipse(90,60,20,20); fill(Blue); ellipse(120,60,20,20); // Now if the mouse is pressed, paint if (mousePressed) { noStroke(); fill(currentColor); if (typeIsRect) { if ((mouseX>140) && (mouseY>20) && (mouseX<190) && (mouseY<70)) { rect(mouseX-25,mouseY-25,50,50); } else { rect(mouseX-10,mouseY-10,20,20); } } else { ellipse(mouseX,mouseY,20,20); } } } void mousePressed() { //ractangles if ((mouseX>20) && (mouseY>20) && (mouseX<40) && (mouseY<40)) { typeIsRect = true; currentColor = color(Yellow); } if ((mouseX>50) && (mouseY>20) && (mouseX<70) && (mouseY<40)) { typeIsRect = true; currentColor = color(Red); } if ((mouseX>80) && (mouseY>20) && (mouseX<100) && (mouseY<40)) { typeIsRect = true; currentColor = color(Green); } if ((mouseX>110) && (mouseY>20) && (mouseX<130) && (mouseY<40)) { typeIsRect = true; currentColor = color(Blue); } if ((mouseX>140) && (mouseY>20) && (mouseX<190) && (mouseY<70)) { typeIsRect = true; currentColor = color(Grey); } //elipses if ((mouseX>20) && (mouseY>50) && (mouseX<40) && (mouseY<70)) { typeIsRect = false; currentColor = color(Yellow); } if ((mouseX>50) && (mouseY>50) && (mouseX<70) && (mouseY<70)) { typeIsRect = false; currentColor = color(Red); } if ((mouseX>80) && (mouseY>50) && (mouseX<100) && (mouseY<70)) { typeIsRect = false; currentColor = color(Green); } if ((mouseX>110) && (mouseY>50) && (mouseX<130) && (mouseY<70)) { typeIsRect = false; currentColor = color(Blue); } }