hey andreas i currently have a drawing app and i implemented your codes in to fit in with my codes and basically im trying to switch colors when i click them.....these are my codes right now
// Color
color BG = color(32);
color Red = color(255,13,13);
color Blue = color(24,22,240);
color Green = color(51,229,52);
color Purple = color(116,41,240);
color Yellow = color(255,244,31);
color Orange = color(255,157,52);
color Brown = color(131,114,70);
color White = color(255);
color Grey = color(175);
color Black = color(0);
//Switching between modes
static final int NONE = 0;
static final int RECTANGLE = 1;
static final int CIRCLE = 2;
static final int TRIANGLE = 3;
//Store current mode
int myDrawMode = NONE;
void setup(){
size(500,500);
background(BG);
smooth();
}
void draw(){
//Draw background of toolbar
fill(255);
strokeWeight(1);
rect (-1, -1, 125, 250);
//Brush Sizes
fill(255);
strokeWeight(1);
rect (-1, 249, 125, 251);
//Draw color selections
stroke(0);
strokeWeight(2);
fill(Red);
ellipse (20, 20, 25, 25);
fill(Blue);
ellipse (60, 20, 25, 25);
fill(Green);
ellipse (100, 20, 25, 25);
fill(Purple);
ellipse (20, 60, 25, 25);
fill(Yellow);
ellipse (60, 60, 25, 25);
fill(Orange);
ellipse (100, 60, 25, 25);
fill(Brown);
ellipse (20, 100, 25, 25);
fill (White);
ellipse (60, 100, 25, 25);
fill (Grey);
ellipse (100, 100, 25, 25);
fill (Black);
ellipse (20, 140, 25, 25);
//Draw line thickness selections
fill (0);
ellipse (60, 295, 5, 5);
ellipse (60, 325, 10, 10);
ellipse (60, 360, 15, 15);
ellipse (60, 400, 25, 25);
ellipse (60, 450, 35, 35);
//Different Modes
if(mousePressed) {
switch(myDrawMode) {
case(RECTANGLE):
fill(255,128);
rect(mouseX, mouseY, 20,20);
break;
case(CIRCLE):
fill(255,128);
ellipse(mouseX, mouseY, 20,20);
break;
case(TRIANGLE):
fill(255,128);
triangle(mouseX-10, mouseY+10, mouseX, mouseY-10,mouseX+10, mouseY+10);
break;
}
}
}
void keyPressed() {
// check which key was pressed and set the
// draw mode accordingly.
switch(key) {
case('0'): myDrawMode = NONE; break;
case('1'): myDrawMode = RECTANGLE; break;
case('2'): myDrawMode = CIRCLE; break;
case('3'): myDrawMode = TRIANGLE; break;
case('4'): background(BG); break;
}
}