🔧Utility functions

Extra functions

extra functions and variable to make it easier to use.

Cache

Each instance comes with an empty variable called 'cache', this is an empty json object. In this you can store any data you want, but this was specially designed so that you can store your images in it.

example:

MayoGL.cache.player = playerImage
//accses the image latter with: MayoGL.cache.player

Functions

setWidth(width: Number) -> sets the width of the canvas
setHeight(height: Number) -> sets the height of the canvas
setPixelSize(size: Number) -> sets the pixel size of the canvas
setAlpha(alpha: Boolean) -> sets if the canvas is transparent
setClearColor(color: String) -> sets the clear colour of the canvas
setCanvas(canvas: Canvas DOM Element) -> hot swap the canvas
setContext(context: Object) -> set the canvas context manually
setAntiAlias(antiAlias: Boolen) -> sets the image smoothing on or off for the canvas
image(url: String) -> create a image
loadInCache(object: Image Object, name: String) -> Save an image to this instances cache with the specified name
loadFromCache(name: String) -> load and image from cache from the specified name

Static Variables

access static variable to change things on the fly eg.:

MayoGL.clearColor = '#000'
Name
Description

canvas: Object

the Canvas Element

width: Number

The width of the canvas

height: Number

the height of the canvas

alpha: Boolean

is the canvas is transparent

clearColor: String

the background colour of the canvas

ctx: Object

the canvas context

pixelSize: Number

the pixel size

antiAlias: Boolean

image smoothing

cache: JSON Object

the image cache

Last updated