xxxxxxxxxx
//cuadrado
color color1;
boolean cambio;
//triangulo
int grosorMax = 25;
int grosorMin = 3;
int grosorVar;
boolean variar;
//circulo
int modulo;
boolean aleatorio = false;
//rectangulo
int tam1 = 3;
int tam2 = 105;
int tamVar;
boolean grande;
//arco
color relleno = color(0);
boolean boton;
//quad
float escalar;
float escalar1 = 1;
float escalar2 = 2;
boolean medir;
//rectangulo2
float velRotacion = 0.0;
float inc = 0;
float rot = 0.0;
float rot1 = 180;
float rot2 = 360;
//cuadrado2
color colores;
boolean diferencia;
//ellipse
int cemaforo1 = (255);
int cemaforo2 = (250);
int cemaforo3 = (250);
void setup() {
size(700, 350);
}
void draw() {
background(150);
println(mouseX);
println(mouseY);
//cuadrado
pushStyle();
noStroke();
fill(color1);
rect(27, 28, 100, 100);
popStyle();
if ( cambio == true) {
color1 = color( 232, 125, 59);
}
else {
color1 = color(106, 123, 188);
}
//triangulo
pushStyle();
strokeWeight(grosorVar);
stroke(255);
noFill();
triangle( 179, 29, 240, 126, 180, 125);
popStyle();
if ( variar == true) {
if ( grosorVar > grosorMin) {
grosorVar -= 1 ;
}
}
else { // if (cambio == false)
if (grosorVar < grosorMax) {
grosorVar += 1;
}
}
//circulo
modulo = width;
int x = modulo;
int y = modulo;
if (aleatorio == true) {
fill(random(255));
}
else {
fill(150);
}
noStroke();
ellipse( 295, 73, 100, 100);
//rectangulo
pushStyle();
fill(102);
rect(372, 41, tamVar, tamVar);
popStyle();
if ( grande == true) {
if ( tamVar > tam1) {
tamVar = tamVar-1 ;
}
}
else { // if (cambio == false)
if (tamVar < tam2) {
tamVar += 1;
}
}
//arco
pushStyle();
fill(relleno);
arc(550, 90, 100, 100, radians(180), radians(360));
popStyle();
if (boton == true) {
fill(0);
ellipse(random(width), random(height), 10, 10);
}
else {
fill(255);
}
//quad
//resetMatrix();
pushMatrix();
pushStyle();
translate(24, 167);
scale(escalar);
fill(204);
quad(0, 0, 127, 125, 127, 50, 29, 60);
popStyle();
popMatrix();
if ( medir == true) {
escalar = 1;
}
else {
escalar = 2;
}
// rectangulo2
pushMatrix();
pushStyle();
translate(200, 200);
rotate(velRotacion);
rectMode(CENTER);
rect(0, 0, 80, 10);
rect(0, 0, 10, 80);
popStyle();
popMatrix();
velRotacion += inc;
//linea
pushMatrix();
pushStyle();
stroke(255);
translate(width/2, 253);
// rot = map(mouseX, 20, width-20, 180, 360);
rot = int(constrain(rot, 180, 360));
rotate(radians(rot));
rect(0, 0, 80, 1);
popStyle();
popMatrix();
println(rot);
//cuadrado 2
pushStyle();
noStroke();
fill(colores);
rect(435, 187, 100, 100);
if ( diferencia == true) {
colores = color( random( 255), random (255), random (255));
}
else {
colores = color(106, 123, 188);
popStyle();
}
//ellipse
if ( mouseX < 614 && mouseX > 564){
cemaforo1 = color(255, 0, 0);
}
else {
cemaforo1 = color(255);
}
pushStyle();
fill(cemaforo1);
ellipse( 589, 180, 50, 50);
popStyle();
println( mouseX);
println( mouseY);
}
//arc
void mousePressed() {
if ((mouseX > 550 - 50) && (mouseX < 550 + 50) && (mouseY > 90 - 50) && (mouseY < 90 + 50)) {
relleno = color(255);
if (boton == true) {
boton = false;
background(200);
}
else if (boton == false) {
relleno = color(0);
boton = true;
}
}
}
void keyPressed() {
if ( key == 'r') {
if ( cambio == true) {
cambio = false;
}
else {
cambio = true;
}
}
if ( key == 'l') {
if ( variar == true) {
variar = false;
}
else {
variar = true ;
}
}
if (key == 'p') {
if (aleatorio == true) {
aleatorio = false;
}
else {
aleatorio = true;
}
}
if ( key == 'e') {
if ( grande == true) {
grande = false;
}
else {
grande= true ;
}
}
if (key == 'o') {
if (medir == true) {
medir = false ;
}
else {
medir = true ;
}
}
if (keyCode == RIGHT) {
inc += 0.01;
}
if (keyCode == LEFT) {
inc -= 0.01;
}
if (keyCode == ' ') {
inc = 0.0;
}
if (key == 'd') {
rot += 5;
}
if (key == 'a'){
rot -= 5 ;
}
if ( key == 'c') {
if ( diferencia == true) {
diferencia = false;
}
else {
diferencia = true;
}
}
}