Created
September 7, 2015 18:43
-
-
Save claytical/1078549d5469782b2432 to your computer and use it in GitHub Desktop.
p5js event functions
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() { | |
// uncomment this line to make the canvas the full size of the window | |
createCanvas(windowWidth, windowHeight); | |
} | |
function draw() { | |
} | |
function keyPressed() { | |
//draw a diagonal line starting from top left corner | |
line(0, 0, width, height); | |
} | |
function keyReleased() { | |
//draw a diagonal line starting from the top right corner | |
line(width, 0, 0, height); | |
} | |
function mousePressed() { | |
ellipse(width/2, 20, 20, 20); | |
} | |
function mouseReleased() { | |
ellipse(width/2, height-20, 20, 20); | |
} | |
function mouseMoved() { | |
line(mouseX, mouseY, pmouseX, pmouseY); | |
} | |
function mouseDragged() { | |
rect(mouseX, mouseY, 10, 10); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment