//Created by Rosalia Escalera //Cecilia Guerrero and Alexandra Trubnikova //Cmps10 //funny colorful character moving from left to right int x; int speed; void setup() { size(800, 600); smooth(); } void draw() { strokeWeight(2); background(200,45,60); ellipseMode(RADIUS); ellipse(200+x, 223, 190, 190); x += speed; speed = 1; //NECK stroke(79, 67, 34); stroke(3, 249, 255); line(266+x, 269, 232+x, 223); line(133+x, 269, 232+x, 223); stroke(3, 249, 255); line(276+x, 257, 376+x, 162);//middle stroke(4, 349, 123); line(278+x, 260, 378+x, 164); stroke(158, 117, 167); fill(129, 130, 100); ellipse(200+x, 100, 100, 100); fill(189, 124, 100); ellipse(210+x, 100, 100, 100); fill(49, 120, 0); ellipse(220+x, 100, 100, 100); fill(38, 120, 190); ellipse(230+x, 100, 100, 100); fill(49, 120, 189); ellipse(240+x, 100, 100, 100); fill(130, 120, 189); ellipse(250+x, 100, 100, 100); ellipse(250+x, 100, 100, 100); ellipse(260+x, 100, 100, 100); ellipse(270+x, 100, 100, 100); //Body noStroke(); fill(100, 200, 179); ellipse(264+x, 377, 33, 33); fill(47, 78, 68); ellipse(219+x, 257, 50, 50); fill(179, 190, 167); ellipse(350+x, 257, 50, 50); fill(139, 49, 189); ellipse(219+x, 257, 25, 25); fill(139, 189, 240); ellipse(350+x, 257, 25, 25); fill(189, 39, 189); ellipse(264+x, 377, 33, 33); fill(48, 100, 40); ellipse(264+x, 327, 33, 3); //Head fill(59, 100, 200); ellipse(276+x, 155, 45, 45); fill(200,69, 90); fill(255, 128, 31); ellipse(288+x, 150, 10, 5); fill(31, 96, 255); ellipse(263+x, 148, 5, 5); fill(93, 255, 31); ellipse(296+x, 130, 4, 4); ellipse(305+x, 162, 3, 3); stroke(3, 249, 255); line(266+x, 269, 233+x, 223); line(133+x, 269, 232+x, 223); } // created by; Rosalia Escalera //Cecilia Guerrero and Alexandra Trubnikova // cmps 10 // when you click on the squares the backround changes colors //---------------------------------------------------------------------------- boolean mouseInRed; boolean mouseInGreen; boolean mouseInBlue; boolean redOn = false; boolean greenOn = false; boolean blueOn = false; int redCenterX, greenCenterX, blueCenterX, rectCenterY, distFromCenter, buttonMaxY, buttonMinY; int bckgrndRed = 0; int bckgrndGreen = 0; int bckgrndBlue = 0; void setup() { size(500,500); distFromCenter = 45; redCenterX = 100; greenCenterX = width/2; blueCenterX = 400; rectCenterY = height/2; buttonMaxY = rectCenterY + distFromCenter; buttonMinY = rectCenterY - distFromCenter; rectMode(CENTER); println("black"); } void draw() { if(redOn) bckgrndRed = 255; else bckgrndRed = 0; if(greenOn) bckgrndGreen = 255; else bckgrndGreen = 0; if(blueOn) bckgrndBlue = 255; else bckgrndBlue = 0; background(bckgrndRed, bckgrndGreen, bckgrndBlue); // the buttons stroke(175); strokeWeight(12); // the Red button fill(255,0,0); rect(redCenterX, rectCenterY, 100, 100); // the Green button fill(0,255,0); rect(greenCenterX, rectCenterY, 100, 100); // the Blue button fill(0,0,255); rect(blueCenterX, rectCenterY, 100, 100); // black boundary when activated stroke(0); strokeWeight(2); noFill(); if(redOn) rect(redCenterX, rectCenterY, 100, 100); if(greenOn) rect(greenCenterX, rectCenterY, 100, 100); if(blueOn) rect(blueCenterX, rectCenterY, 100, 100); } void mousePressed() { mouseInRed = (mouseX > redCenterX - distFromCenter) && (mouseX < redCenterX + distFromCenter) && (mouseY > buttonMinY) && (mouseY < buttonMaxY); if(mouseInRed) redOn = !redOn; mouseInGreen = (mouseX > greenCenterX - distFromCenter) && (mouseX < greenCenterX + distFromCenter) && (mouseY > buttonMinY) && (mouseY < buttonMaxY); if(mouseInGreen) greenOn = !greenOn; mouseInBlue = (mouseX > blueCenterX - distFromCenter) && (mouseX < blueCenterX + distFromCenter) && (mouseY > buttonMinY) && (mouseY < buttonMaxY); if(mouseInBlue) blueOn = !blueOn; if(mouseInRed | mouseInGreen | mouseInBlue) { //Calls out current colors if(redOn && greenOn && blueOn) { println("white"); } else if(redOn && greenOn) { println("yellow"); } else if(redOn && blueOn) { println("magenta"); } else if(greenOn && blueOn) { println("cyan"); } else if(redOn) { println("red"); } else if(greenOn) { println("green"); } else if(blueOn) { println("blue"); } else { println("black"); } } }