Skip to content

Instantly share code, notes, and snippets.

@mimetaur
Last active October 24, 2019 19:29
Show Gist options
  • Save mimetaur/37b8675572661660b4b28f43bf1fc753 to your computer and use it in GitHub Desktop.
Save mimetaur/37b8675572661660b4b28f43bf1fc753 to your computer and use it in GitHub Desktop.
Code 1 2019: Homework Week 5 - Sketch 2 solution
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