/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://designuniandes.sketchpad.cc/sp/pad/view/ro.gQPO0zmALVD/rev.5
*
* authors:
* Juan Felipe Paternina
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
// botones del 1 al 6. Borrar y 5 colores
int boton1x=10, boton1y=10, boton1w=20;
int boton2x=10, boton2y=60, boton2w=20;
int boton3x=10, boton3y=90, boton3w=20;
int boton4x=10, boton4y=120, boton4w=20;
int boton5x=10, boton5y=150, boton5w=20;
int boton6x=10, boton6y=180, boton6w=20;
// botones del 7 al 11. Diferentes trazos
int boton7x=10, boton7y=230, boton7w=20;
int boton8x=10, boton8y=260, boton8w=20;
int boton9x=10, boton9y=290, boton9w=20;
int boton10x=10, boton10y=320, boton10w=20;
int boton11x=10, boton11y=350, boton11w=20;
int herramientica = 1;
int colorcito = 1;
boolean otro = false;
void setup() {
size(400, 400);
background(254);
}
void draw() {
// verificar, borrar y resetar boton 1
if (mousePressed == true) {
if ((mouseX>boton1x)&&(mouseX<boton1x+boton1w)&&(mouseY>boton1y)&&(mouseY<boton1y+boton1w)) {
background(255);
colorcito = 1;
herramientica = 0;
}
}
// verificar y escoger boton 2
if (mousePressed == true) {
if ((mouseX>boton2x)&&(mouseX<boton2x+boton2w)&&(mouseY>boton2y)&&(mouseY<boton2y+boton2w)) {
colorcito = 1;
}
}
// verificar y escoger boton 3
if (mousePressed == true) {
if ((mouseX>boton3x)&&(mouseX<boton3x+boton3w)&&(mouseY>boton3y)&&(mouseY<boton3y+boton3w)) {
colorcito = 2;
}
}
// verificar y escoger boton 4
if (mousePressed == true) {
if ((mouseX>boton4x)&&(mouseX<boton4x+boton4w)&&(mouseY>boton4y)&&(mouseY<boton4y+boton4w)) {
colorcito = 3;
}
}
// verificar y escoger boton 5
if (mousePressed == true) {
if ((mouseX>boton5x)&&(mouseX<boton5x+boton5w)&&(mouseY>boton5y)&&(mouseY<boton5y+boton5w)) {
colorcito = 4;
}
}
if (mousePressed == true) {
if ((mouseX>boton6x)&&(mouseX<boton6x+boton6w)&&(mouseY>boton6y)&&(mouseY<boton6y+boton6w)) {
colorcito = 5;
}
}
if (mousePressed == true) {
if ((mouseX>boton7x)&&(mouseX<boton7x+boton7w)&&(mouseY>boton7y)&&(mouseY<boton7y+boton7w)) {
herramientica = 1;
}
}
if (mousePressed == true) {
if ((mouseX>boton8x)&&(mouseX<boton8x+boton8w)&&(mouseY>boton8y)&&(mouseY<boton8y+boton8w)) {
herramientica = 2;
}
}
if (mousePressed == true) {
if ((mouseX>boton9x)&&(mouseX<boton9x+boton9w)&&(mouseY>boton9y)&&(mouseY<boton9y+boton9w)) {
herramientica = 3;
}
}
if (mousePressed == true) {
if ((mouseX>boton10x)&&(mouseX<boton10x+boton10w)&&(mouseY>boton10y)&&(mouseY<boton10y+boton10w)) {
herramientica =4;
}
}
if (mousePressed == true) {
if ((mouseX>boton11x)&&(mouseX<boton11x+boton11w)&&(mouseY>boton11y)&&(mouseY<boton11y+boton11w)) {
herramientica = 5;
}
}
// escoje color para pintar
if (colorcito==1)
{
stroke(mouseX, mouseY, 100);
fill(mouseX, mouseY, 100);
}
else if (colorcito==2) {
stroke(100, mouseY, mouseX);
fill(100, mouseY, mouseX);
}
else if (colorcito==3) {
stroke(0, 0, 255);
fill(0, 0, 255);
}
else if (colorcito==4) {
stroke(0, 255, 0);
fill(0, 255, 0);
}
else if (colorcito==5) {
stroke(255, 0, 0);
fill(255, 0, 0);
}
// escoje herramienta para pintar
if ( mousePressed && mouseX > 50){
if (herramientica==1) {
line(mouseX, mouseY, mouseX+20, mouseY-20);
}
else if (herramientica==2) {
noStroke();
ellipse(mouseX, mouseY, 5, 5);
}
else if (herramientica==3) {
noStroke();
triangle(mouseX, mouseY, mouseX+12, mouseY, mouseX+6, mouseY+7);
triangle(mouseX, mouseY+10, mouseX+12, mouseY+10, mouseX+10, mouseY+7+10);
}
else if (herramientica==4) {
if ( otro)
{
rect(mouseX, mouseY, 6, 6);
otro=!otro;
}
else
{
rect(mouseX, mouseY, 2,2);
otro=!otro;
}
noStroke();
}
else if (herramientica==5) {
if ( otro)
{
ellipse(mouseY, mouseX, 5, 4);
otro=!otro;
}
else
{
ellipse (mouseX,mouseY,4,5);
otro=!otro;
}
}
noFill();
}
fill(240);
noStroke();
rect(0,0,50,400);
//pinta los botones
fill(255);
rect(boton1x, boton1y, boton1w, boton1w);
fill(0);
text("B",boton1x+5,boton1y+15);
fill(255, 112, 3);
rect(boton2x, boton2y, boton2w, boton2w);
fill(5, 230, 255);
rect(boton3x, boton3y, boton3w, boton3w);
fill(0, 0, 255);
rect(boton4x, boton4y, boton4w, boton4w);
fill(0, 255, 0);
rect(boton5x, boton5y, boton5w, boton5w);
fill(255, 0, 0);
rect(boton6x, boton6y, boton5w, boton5w);
noFill();
stroke(0);
rect(boton7x, boton7y, boton5w, boton5w);
fill(50);
line(boton7x+17,boton7y+3,boton7x+3,boton7y+17);
noFill();
stroke(0);
rect(boton8x, boton8y, boton5w, boton5w);
fill(50);
ellipse(boton8x+10,boton8y+10,5,5);
noFill();
stroke(0);
rect(boton9x, boton9y, boton5w, boton5w);
fill(50);
triangle( boton9x+5,boton9y+8,boton9x+17,boton9y+8,boton9x+10,boton9y+13);
noFill();
stroke(0);
rect(boton10x, boton10y, boton5w, boton5w);
fill(50);
rect (boton10x+5,boton10y+5,10,10);
noFill();
stroke(0);
rect(boton11x, boton11y, boton5w, boton5w);
fill(50);
text("S",boton11x+6,boton11y+15);
}