Classes
Methods
backend(backend) → {AppBuilder}
Specify the default backend to use for the canvas
drawing.
Parameters:
Name | Type | Description |
---|---|---|
backend |
Backends | the backend to use |
Returns:
- the app builder
- Type
- AppBuilder
framerate(frameRate) → {AppBuilder}
Set the loop mode to LoopMode.FrameRate(frameRate).
Shorthand for loopmode(LoopMode.FrameRate(frameRate))
Parameters:
Name | Type | Description |
---|---|---|
frameRate |
number | the framerate the app should run at |
Returns:
- Type
- AppBuilder
keyPress(keyPressedFn) → {AppBuilder}
The default function that is called when a key is pressed down.
Parameters:
Name | Type | Description |
---|---|---|
keyPressedFn |
* | the key press function |
Returns:
- Type
- AppBuilder
loopmode(mode) → {AppBuilder}
Specify the loop mode that the app should use.
Parameters:
Name | Type | Description |
---|---|---|
mode |
LoopMode | the loop mode to use |
Returns:
- Type
- AppBuilder
model(modelFn)
The default model function that the app will call before the
first frame.
Parameters:
Name | Type | Description |
---|---|---|
modelFn |
* | the model function that is called before the first frame |
Returns:
- the app builder
mouseMove(mouseMoveFn) → {AppBuilder}
The default function that is called when the mouse is moved.
Parameters:
Name | Type | Description |
---|---|---|
mouseMoveFn |
* | the mouse move function |
Returns:
- itself
- Type
- AppBuilder
mousePress(mousePressedFn) → {AppBuilder}
The default function that is called when the mouse is moved.
Parameters:
Name | Type | Description |
---|---|---|
mousePressedFn |
* | the mouse press function |
Returns:
- Type
- AppBuilder
ntimes(times) → {AppBuilder}
Set the loop mode to LoopMode.NTimes(times).
Shorthand for loopmode(LoopMode.NTimes(times))
Parameters:
Name | Type | Description |
---|---|---|
times |
number | iterations the app should run |
Returns:
- Type
- AppBuilder
once() → {AppBuilder}
Set the loop mode to LoopMode.Once().
Shorthand for loopmode(LoopMode.Once()).
Returns:
- Type
- AppBuilder
parent(parentId) → {AppBuilder}
Specify the DOM Element by its ID which should
be the parent of the canvas that the app creates.
Parameters:
Name | Type | Description |
---|---|---|
parentId |
string | the DOM id |
Returns:
- itself
- Type
- AppBuilder
quickstart(viewFn, w, h)
Quickly start an app.
Short-hand for .view(viewfn).size(w, h).run();
If no width and height are passed the size of the
canvas is set to 400x400 pixels.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
viewFn |
* | the view function to use | |
w |
number | 400 | the width of the app, default is 400 |
h |
number | 400 | the height of the app, default is 400 |
run()
Build and run an @type {App} with the specified parameters.
This function will not return until the app has exited.
size(w, h) → {AppBuilder}
Specify the default canvas size in points.
If the size is not specified or less or equal to zero,
the default size of 100x100 will be used.
Parameters:
Name | Type | Description |
---|---|---|
w |
number | width |
h |
number | height |
Returns:
- the app builder
- Type
- AppBuilder
sizeSz(sz) → {AppBuilder}
Specify the default canvas size using the @type {Size} type.
If the size is less or equal to zero,
the default size will be 100x100 pixels.
Parameters:
Name | Type | Description |
---|---|---|
sz |
Size | the size |
Returns:
- Type
- AppBuilder
view(viewFn) → {AppBuilder}
The default view function that the app will call to allow
you to draw to the current frame.
Parameters:
Name | Type | Description |
---|---|---|
viewFn |
* | the view function that is called every frame |
Returns:
- the app builder
- Type
- AppBuilder