-
Notifications
You must be signed in to change notification settings - Fork 430
Justin Windle edited this page May 27, 2013
·
17 revisions
Passed to the Sketch.create
method.
-
fullscreen
Default:true
-
autostart
Default:true
Otherwise callstart()
-
autoclear
Default:true
Whether to clear the context before each call todraw
. Otherwise callclear()
-
autopause
Default:true
Whether to pause the animation on window blur and resume on focus -
container
Default:document.body
Where to put the sketch context -
interval
Default:1
The update / draw interval (2
will update every 2 frames, etc) -
globals
Default:true
Add global properties and methods to thewindow
-
retina
Default:false
Resize for best appearance on retina displays. Can be slow due to so many pixels! -
type
DefaultSketch.CANVAS
Possible values:Sketch.CANVAS
,Sketch.WEB_GL
andSketch.DOM
-
create
Creates and returns a new sketch. Arguments:options
Optional hash including any number of the above options -
augment
Augments an existing context, giving it sketch properties and functionality. This is called internally bycreate
once a new context is created. Arguments:context
The context to augment -
install
Installs sketch globals into the context provided. This is called internally bycreate
onself
unless theglobals
flag is set tofalse
. Arguments:context
The context to install globals into
start
stop
toggle
clear
destroy
Implement these methods on your sketch instance (or pass them to create
inside the options
hash).
setup
update
draw
touchstart
touchmove
touchend
mouseover
mousedown
mousemove
mouseout
mouseup
click
keydown
keyup
resize
-
mouse
Containsx
,y
,ox
,oy
,dy
anddy
, representing the mouse or primary touch. -
touches
List of current touches with same structure asmouse
. On the desktop, the 0th element represents the mouse. -
dragging
Whether the mouse is down / the user is dragging -
running
Whether the animation loop is running (modified by thestart
andstop
methods) -
width
Current viewport width -
height
Current viewport height -
keys
A hash of booleans indicating whether each key is currently pressed, e.gsketch.keys.SPACE
-
millis
The total runtime of the sketch in milliseconds -
now
The current time in milliseconds -
dt
The delta time between the current and previous frame in milliseconds
-
CANVAS
Enumeration for the Canvastype
-
WEBGL
Enumeration for the WebGLtype
-
DOM
Enumeration for the DOMtype
-
instances
A list of all current Sketch instances
These are safely mixed into the window object for quick access, e.g: sin( random( TWO_PI ) )
. You can prevent this happening by passing globals:false
when calling create
and/or add this properties to any object yourself by calling Sketch.install( context )
-
random
Accepts single values, ranges and Arrays, e.g:random( 10, 20 )
orrandom( colours )
-
lerp
Arguments:min
max
amount
. Interpolate betweenmin
andmax
by the factoramount
-
map
Arguments:num
minA
maxA
minB
maxB
. Mapnum
from the rangeminA
/maxA
to the rangeminB
/maxB
PI
TWO_PI
HALF_PI
QUARTER_PI
E
LN10
LN2
LOG2E
LOG10E
SQRT1_2
SQRT2
abs
acos
asin
atan
ceil
cos
exp
floor
log
round
sin
sqrt
tan
atan2
pow
max
min