CanvasRenderer Class
A canvas renderer base class.
Constructor
CanvasRenderer
(
-
[options]
Parameters:
-
[options]Object optional- The settings.
-
[dt=1/60]Number optional- The update rate in seconds.
-
[clearCanvas=true]Boolean optional- Whether the canvas should automatically be cleared.
-
[enabled=true]Boolean optional- Whether the animation should be rendered. If set to false, the render function will merely update the time.
-
[size]Number optional- The canvas size.
Item Index
Properties
Methods
_render
(
private
-
now
Renders the animation.
Parameters:
-
nowDOMHighResTimeStamp- The time since the page was loaded.
Throws:
An error if update() or draw() hasn't been implemented.
draw
()
Abstract draw method.
Throws:
An error if not implemented.
render
()
The animation loop.
This ugly thing will evolve into an arrow function some day!
update
(
-
elapsed
Abstract update method.
This method will be called by the render function at a maximum rate of x fps where x corresponds to the refresh rate of the used monitor.
Parameters:
-
elapsedNumber- The time since the last update call in milliseconds.
Throws:
An error if not implemented.
Properties
accumulator
Number
private
Used for time based rendering. Milliseconds.
canvas
HTMLCanvasElement
The canvas.
clearCanvas
Boolean
Clear flag.
ctx
CanvasRenderingContext2D
private
The rendering context.
dt
Number
Delta time in milliseconds.
enabled
Boolean
Enabled flag.
now
Number
private
Used for time based rendering. Milliseconds.
size
Array
The size of the canvas.
Example:
[width, height]
then
Number
private
Used for time based rendering. Milliseconds.
