Skip to content

Instantly share code, notes, and snippets.

@zamfi
Created February 3, 2021 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zamfi/d39f549e0142ed28def910e52ca92ec6 to your computer and use it in GitHub Desktop.
Save zamfi/d39f549e0142ed28def910e52ca92ec6 to your computer and use it in GitHub Desktop.
// "number in box" - try clicking in the window
// this is the "data"
var c = 0;
var x = 50;
var y = 50;
function setup() {
createCanvas(340, 340);
}
// this is the "render" function
function draw() {
background(220);
noStroke();
fill('red');
rect(x, y, width/4, height/4);
fill(0);
textSize(32);
text(c, x+10, y+32);
}
// this function detects a mouse click (an event)
function mousePressed() {
x = mouseX + 0;
y = mouseY + 0;
c = c + 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment