Skip to content

Instantly share code, notes, and snippets.

@shiffman
Created January 8, 2015 10:17
Show Gist options
  • Select an option

  • Save shiffman/7b2cfbfc1706dd203f9c to your computer and use it in GitHub Desktop.

Select an option

Save shiffman/7b2cfbfc1706dd203f9c to your computer and use it in GitHub Desktop.
DOM Sample p5
var canvas;
var button;
function setup() {
// Make a canvas
canvas = createCanvas(100,100);
// Make an HTML DOM element, a button!
// The button will have the word "submit" in it
button = createButton("submit");
// Set the position in the browser window (separate from the canvas)
button.position(10,120);
// The function "makeItRed" is a callback for
// when the button is pressed
button.mousePressed(makeItRed);
background(0);
}
function makeItRed() {
background(255,0,0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment