Last active
October 24, 2019 19:29
-
-
Save mimetaur/37b8675572661660b4b28f43bf1fc753 to your computer and use it in GitHub Desktop.
Code 1 2019: Homework Week 5 - Sketch 2 solution
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
function setup() { | |
createCanvas(400, 400); | |
} | |
function draw() { | |
background(255); | |
drawButton(width / 2, height / 2, 200, 100); | |
} | |
function drawButton(x, y, w, h) { | |
let clickedInsideButton = true; | |
if (mouseIsPressed && mouseX >= x && mouseX <= x+w && mouseY >= y && mouseY <= y+h){ | |
fill(200, 100, 0); | |
} else { | |
fill(100, 200, 0); | |
} | |
rectMode(CENTER); | |
rect(x, y, w, h, 10) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment