Gets the center coordinate of the canvas
Gets the drawing context
Returns the width or height, whichever is largest
Returns the width or height, whichever is smallest
Gets the current scaling ratio being used to compensate for high-DPI display
Returns a Scaler that converts from relative to absolute coordinates. This is based on the canvas size.
// Assuming a canvas of 800x600
toAbsolute({ x: 1, y: 1 }); // { x: 800, y: 600}
toAbsolute({ x: 0, y: 0 }); // { x: 0, y: 0}
toAbsolute({ x: 0.5, y: 0.5 }); // { x: 400, y: 300}
Returns a Scaler that converts from absolute to relative coordinates. This is based on the canvas size.
// Assuming a canvas of 800x500
toRelative({ x: 800, y:600 }); // { x: 1, y: 1 }
toRelative({ x: 0, y: 0 }); // { x: 0, y: 0 }
toRelative({ x: 400, y: 300 }); // { x: 0.5, y: 0.5 }
Adds event listener.
Event name
Event handler
Protected
fireFire event
Type of event
Arguments for event
Remove event listener
A wrapper for the CANVAS element that scales the canvas for high-DPI displays and helps with resizing.
Draw whenever it is resized using the 'resize' event
Or provide a function when initialising:
Automatically draw at animation speeds: