i am creating a simpleDraw application and i have built 8 different colours options and 6 line options. What is happening is that the last line thickness (very thick) and colour (white/earaser) are the ones that are appearing and i can't get the selector to work where the user can select a particular line thickness and particular colour to draw. here is my code.
int ylw = color(255,243,0);
int gr = color (45,255,0);
int bl = color (0,249,255);
int pur = color (131,105,203);
int bck = color (130,129,134);
int r = color (255,46,78);
int oj = color (255,123,41);
int w = color (255);
int border = 180;
int newColor= 0 ;//new colour
int lineWidth = 2;//new line
// basic setup
void setup() {
size (800,900);
background (255);
frameRate(60);
smooth();
stroke(255);
fill(ylw);//ylw
ellipse(100,100,90,90);//size and position of circles 1 thru 8
fill(gr); //gr
ellipse(100,200,90,90);
fill(bl);//bl
ellipse(100,300,90,90);
fill (pur);//pur
ellipse(100,400,90,90);
fill(bck);//bck
ellipse(100,500,90,90);
fill(r);//r
ellipse(100,600,90,90);
fill(oj);//oj
ellipse(100,700,90,90);
fill(w);//w eraser
stroke(200);
ellipse(100,800,90,90);
strokeWeight(1);
line (0,150,50,150);//line 1
strokeWeight (7);
line (0,250,50,250);
strokeWeight (11);
line (0,345,50,345);
strokeWeight (15);
line (0,444,50,444);
strokeWeight(25);
line(0,543,50,543);
strokeWeight(38);
line(0,648,50,648);
}
void draw () {
}
//make line not go into left margin and setup colour/line click on
void mouseDragged(){
if (mouseX >= border)
{
strokeWeight(lineWidth);
stroke(newColor);
line(pmouseX,pmouseY,mouseX,mouseY);
}
}
// lines and thickness
void mouseReleased () {
if (mouseX > 120 && mouseX < 180 && mouseY > 0 && mouseY < 50) {//thin line 1// do i need a default line
lineWidth = 1;
} else {
lineWidth = 1;
}
if (mouseX > 220 && mouseX < 270 && mouseY > 0 && mouseY < 50) {//thin line 2
} else {
lineWidth = 7;
}
if (mouseX > 320 && mouseX < 360 && mouseY > 0 && mouseY < 50) {//thin line 3
} else {
lineWidth = 11;
}
if (mouseX > 420 && mouseX < 460 && mouseY > 0 && mouseY < 50) {//thin line 4
} else {
lineWidth = 15;
}
if (mouseX > 520 && mouseX < 570 && mouseY > 0 && mouseY < 50) {//thin line 5
} else {
lineWidth = 25;
}
if (mouseX > 620 && mouseX < 670 && mouseY > 0 && mouseY < 50) {//thin line 6
} else {
lineWidth = 38;
}
if (mouseX > 80 && mouseX < 80 && mouseY > 90 && mouseY < 90) {// ist circle yellow
} else {
newColor = ylw;
}
if (mouseX > 80 && mouseX < 180 && mouseY > 90 && mouseY < 90) {//2 circle green
} else {
newColor = gr;
}
if (mouseX > 80 && mouseX < 280 && mouseY > 90 && mouseY < 90) {//3 circle blue
} else {
newColor = bl;
}
if (mouseX > 80 && mouseX < 380 && mouseY > 90 && mouseY < 90) {//4 circle purple
} else {
newColor = pur;
}
if (mouseX > 80 && mouseX < 480 && mouseY > 90 && mouseY < 90) {//5 circle black
} else {
newColor = bck;
}
if (mouseX > 80 && mouseX < 580 && mouseY > 90 && mouseY < 90) {//6 circle red
} else {
newColor = r;
}
if (mouseX > 80 && mouseX < 680 && mouseY > 90 && mouseY < 90) {//7 circle orange
} else {
newColor = oj;
}
if (mouseX > 80 && mouseX < 780 && mouseY > 90 && mouseY < 90) {//8 circle white/eraser