-
draw()
-
Handles the graphic generation, drawing rings or the masks to the canvas when
people are detected by the FACE API.
- Source:
-
failure(error)
-
Logs the error to the console when the FACE.sendImage() call fails.
Parameters:
Name |
Type |
Description |
error |
|
The error response from the sendImage() request. |
- Source:
-
forceHttps()
-
Redirects the page to use https protocol if it is not.
- Source:
-
keyTyped()
-
Handles the 'f' key to freeze the canvas.
- Source:
-
maybe(threshold)
-
Returns true or false randomly depending on the threshold that is passed in.
Parameters:
Name |
Type |
Description |
threshold |
int
|
The % threshold to be used for returning true. |
- Source:
-
MoodGif(w, h, gif, maxFramecount)
-
Creates a new MoodGif object, which is a gif image relating to the person's
mood, plotted from an initial x,y position, width, height, drawn until it hits
a maxFramecount.
Parameters:
Name |
Type |
Description |
w |
int
|
The starting width of the mask. |
h |
int
|
The starting height of the mask. |
gif |
gif
|
The gif animation. |
maxFramecount |
int
|
The number of frames the mask will be drawn for. |
- Source:
-
MoodMask(x, y, w, h, img, maxFramecount)
-
Creates a new MoodMask object, which is a mask image relating to the person's
mood, plotted from an initial x,y position, width, height, drawn until it hits
a maxFramecount.
Parameters:
Name |
Type |
Description |
x |
int
|
The starting x position of the mask. |
y |
int
|
The starting y position of the mask. |
w |
int
|
The starting width of the mask. |
h |
int
|
The starting height of the mask. |
img |
img
|
The image of the mask. |
maxFramecount |
int
|
The number of frames the mask will be drawn for. |
- Source:
-
MoodRing(x, y, w, h, color)
-
Creates a new MoodRing object, which is a group of 4 arcs of random lengths,
plotted from an initial x,y position, width, height, and color from the FACE
API.
Parameters:
Name |
Type |
Description |
x |
int
|
The starting x position of the ring. |
y |
int
|
The starting y position of the ring. |
w |
int
|
The starting width of the ring. |
h |
int
|
The starting height of the ring. |
color |
string
|
The starting color of the ring. |
- Source:
-
parseResponse(result)
-
Parses the JSON response returned from the FACE API.
Parameters:
Name |
Type |
Description |
result |
JSON
|
The response from the FACE API. |
- Source:
-
sendDetectRequest()
-
Sends the request to the FACE API, calling parseResponse() on success, or
failure() on failure.
- Source:
-
setup()
-
Runs on startup, setting the framerate, creating the canvas, and initializing
the webcam capture.
- Source:
-
startCapture()
-
Initializes the webcam capture, taking a snapshot and sending the request every
1.1 seconds.
- Source:
-
windowResized()
-
Called whenever the page is resized, adjusts canvas to the new windowWidth and
windowHeight, and calculates the scale variables (ratiow, ratioh).
- Source: