Canvas Interaction¶
Methods¶
resize(w, h);¶
Sets the width and height in pixels of the canvas.
Parameters Variable Description wNew width of canvas hNew height of canvas
Variables¶
keyCode¶
Returns a number that corresponds to a key on the keyboard.
keyDown = function(){};¶
When assigned a function, the function’s code will run when a key is pressed down.
keyFocus¶
Returnstrueif the canvas is catching key events.
keyIsPressed¶
Returnstrueif a key is pressed
keyPressed = function(){};¶
When assigned a function, the function’s code will run when a key is held down.
keys¶
keys[code] = trueif the key is down, andkeys[code] = falsewhen the key is up. If a key hasn’t been pressed yet,keys[code] = undefined.codeis thekeyCodeof a key.
keyUp = function(){};¶
When assigned a function, the function’s code will run when a key is released.
key¶
Returns the character for the key.
mouseButton¶
ReturnsLEFT, CENTER, RIGHTdepending on the mouse button pressed.
mouseClicked = function(){};¶
When assigned a function, the function’s code will run when a mouse button is pressed down.
mouseDragged = function(){};¶
When assigned a function, the function’s code will run when the mouse is moved while a button is held down.
mouseDown = function(){};¶
When assigned a function, the function’s code will run when a mouse button is held down.
mouseFocus¶
Returns
trueif the canvas is catching clicking events.
trueif inside canvas andfalseif outside canvas.
mouseMoved = function(){};¶
When assigned a function, the function’s code will run when the mouse is moved over the canvas.
mouseOver = function(){};¶
When assigned a function, the function’s code will run when the mouse is moved over the canvas.
mouseOut = function(){};¶
When assigned a function, the function’s code will run when the mouse leaves the canvas.
mousePressed = function(){};¶
When assigned a function, the function’s code will run when a mouse button is held down.
mouseReleased = function(){};¶
When assigned a function, the function’s code will run when a mouse button is released.
negativeMouse¶
Set totrueto havemouseXandmouseYreturn negative values.