Digital Craft Drawing Pad

int lineColor = 0;
boolean insideGrid = false;
void setup() {
size(800,800);
background(95,95,95);
stroke(0);
rect(50,100,700,650,20);
rect(50,30,50,50,20);
fill(255);
rect(150,30,50,50,20);
fill(246,31,31);
rect(250,30,50,50,20);//red square
fill(255,255,0);
rect(350,30,50,50,20); // yellow square
fill(0,128,255);
rect(450,30,50,50,20);//blue square
fill(0);
rect(550,30,50,50,20);
}

void inside(int x, int y){

if(mouseX<=800 && mouseX>=100 && mouseY<=700 && mouseY>=105){
insideGrid=true;
}
else{
insideGrid=false;
}
}

void update(int x, int y){
if (mousePressed && mouseX>=250 && mouseX<=300 && mouseY>=30 && mouseY<=80){
lineColor=1;
}
if (mousePressed && mouseX>=150 && mouseX<=200 && mouseY>=30 && mouseY<=80){
lineColor=4;
}
else if (mousePressed && mouseX>=350 && mouseX<=400 && mouseY>=30 && mouseY<=80){
lineColor = 2;
}
else if (mousePressed && mouseX>=450 && mouseX<=500 && mouseY>=30 && mouseY<=80){
lineColor = 3;
}
else if(mousePressed && mouseX>=550 && mouseX<=600 && mouseY>=30 && mouseY<=80){
lineColor = 0;
}
}

 

void draw(){
update(mouseX, mouseY);
inside(mouseX,mouseY);
if(mousePressed && insideGrid && lineColor==0){
stroke(0);
line(mouseX,mouseY,pmouseX,pmouseY);
}
else if(mousePressed && insideGrid && lineColor==4){
strokeWeight(10);
stroke(255);
line(mouseX,mouseY,pmouseX,pmouseY);
}
else if(mousePressed && insideGrid && lineColor==1){
stroke(246,31,31);
line(mouseX,mouseY,pmouseX,pmouseY);
}
else if(mousePressed && insideGrid && lineColor==2){
stroke(255,255,0);
line(mouseX,mouseY,pmouseX,pmouseY);
}
else if(mousePressed && insideGrid && lineColor==3){
stroke(0,128,255);
line(mouseX,mouseY,pmouseX,pmouseY);
}

}

Leave a reply

Skip to toolbar