See it here
- canvas
- dataMap
- drawCell
- gridColour
- drawPart
- clearPart
- drawBeard
- drawShades
- drawFace
- clearAll
- animation
- stopAnimation
- tearLoop
- dropShades
- growBeard
- tearAnimation
- beardAnimation
- shadesAnimation
- mouse
- addEventListener
COM1008 Assignement 2 Author: Craig de Gouveia Last Modified: 06/12/2017
Parameters
data
Parameters
x
int coordinate of celly
int coordinate of cellwidth
int of cellheight
int of cellc
string string representation of a colour, such as rgb(0,0,0), of cell
Parameters
index
int of colour from palette array
Returns any string representation of colour
Maps over a 2d array and plots each value in the canvas as a grid reference
Parameters
context
any to execute againstgrid
any 2d array of pixels for canvasox
any offset value for x coordinateoy
any offset value for y coordinate
Maps over a 2d array and clears any solid pixels to ensure clean rendering and animations
Parameters
context
any to execute againstgrid
any 2d array of pixels for canvasox
any offset value for x coordinateoy
any offset value for y coordinate
Draw the beard part in a desired location on any face
Draw the shades part in a desired location on any face
Cleanly draws a face in the desired location. Checks for any additional features and renders them.
Parameters
face
Clears the entire canvas
This ensures that an animation does not get triggered multiple times. Thus preventing performance issues and other animation bugs.
Type: Function
Parameters
cb
animation executes the defined animation function callback
Stops the currently running animation
Loops the Y coordinate of the tear for 200 frames
Updates the Y coordinate for the shades and stops when the eyes are reached
Updates the y coordinate of the additional beard until it reaches max length
Renders the tear when a user clicks on the eye
Renders the beard growth when a user clicks an already bearded chin
Renders the shades dropping down from off screen when a user clicks on the forehead
This handles the logic for what happens when a user clicks on a particular part of the canvas
Parameters
evt
any mouse event passed in to function
Controls for the buttons on the page to change between expressions. In most cases some variables are reinitialised or redrawn.