Created
February 11, 2020 21:58
-
-
Save slambert/b56c613e9444854367eeb95f1fbe0110 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Color Palette example sketch | |
| includes examples of: | |
| boolean variables | |
| if/else | |
| mousepressed | |
| relational operators (> < == !=) | |
| Steve Lambert February 11, 2020 | |
| */ | |
| color darkBlue = color(34,83,120); | |
| color medBlue = color(22,149,163); | |
| color lightBlue = color(172,240,242); | |
| color offWhite = color(243,255,226); | |
| color orange = color(235,127,0); | |
| float circleWidth = 75.5; // <-- width of my circles! | |
| boolean mouseButtonSwitch = false; | |
| void setup() { | |
| size(1000, 200); | |
| background(offWhite); | |
| noStroke(); | |
| println("setup done"); | |
| } // end setup | |
| void draw() { | |
| //println("mousex = " + mouseX); | |
| //println("mousey = " + mouseY); | |
| println("button = " + mouseButtonSwitch); | |
| if(mouseButtonSwitch == false){ | |
| background(offWhite); | |
| println("false"); | |
| } else { | |
| background(lightBlue); | |
| println("true"); | |
| } | |
| //Circle 1 | |
| if(mouseX < width/5){ | |
| fill(darkBlue); | |
| }else{ | |
| fill(orange); | |
| } | |
| ellipse(width/5*1, height/2, circleWidth, circleWidth); | |
| // Circle 2 | |
| if(mouseX < width/5*2){ | |
| fill(medBlue); | |
| }else{ | |
| fill(orange); | |
| } | |
| ellipse(width/5*2, height/2, circleWidth, circleWidth); | |
| // Circle 3 | |
| if(mouseX < width/5*3){ | |
| fill(lightBlue); | |
| }else{ | |
| fill(orange); | |
| } | |
| // end change color | |
| ellipse(width/5*3, height/2, circleWidth, circleWidth); | |
| if(mouseX > width/5*4 || mouseX < width/5*1){ // mouse is on right 20% or left 80% | |
| fill(orange); | |
| }else{ | |
| fill(lightBlue); | |
| } | |
| // Circle 4 | |
| ellipse(width/5*4, height/2, circleWidth, circleWidth); | |
| } | |
| void mousePressed(){ | |
| mouseButtonSwitch = !mouseButtonSwitch; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment