me.Renderer(canvas, width, height, optionsopt)

new Renderer(canvas, width, height, optionsopt)

a base renderer object

Parameters:
Name Type Attributes Description
canvas HTMLCanvasElement

The html canvas tag to draw to on screen.

width Number

The width of the canvas without scaling

height Number

The height of the canvas without scaling

options Object <optional>

The renderer parameters

Properties
Name Type Attributes Default Description
doubleBuffering Boolean <optional>
false

Whether to enable double buffering

antiAlias Boolean <optional>
false

Whether to enable anti-aliasing, use false (default) for a pixelated effect.

failIfMajorPerformanceCaveat Boolean <optional>
true

If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.

transparent Boolean <optional>
false

Whether to enable transparency on the canvas (performance hit when enabled)

blendMode Boolean <optional>
"normal"

the default blend mode to use ("normal", "multiply")

subPixel Boolean <optional>
false

Whether to enable subpixel rendering (performance hit when enabled)

verbose Boolean <optional>
false

Enable the verbose mode that provides additional details as to what the renderer is doing

zoomX Number <optional>
width

The actual width of the canvas with scaling applied

zoomY Number <optional>
height

The actual height of the canvas with scaling applied

Extends

Classes

Texture

Members

static isContextValid

true if the current rendering context is valid

Default Value:
  • true type {Boolean}

settings :Object

The given constructor options

Methods

static drawShape()

Deprecated:
  • since 6.3.0
See:

clear()

prepare the framebuffer for drawing a new frame

clearMask()

disable (remove) the rendering mask set through setMask.

See:
  • setMask

clearTint()

clear the rendering tint set through setTint.

See:
  • setTint

fill(shape)

fill the given shape

Parameters:
Name Type Description
shape me.Rect | me.Polygon | me.Line | me.Ellipse

a shape object to fill

getBlendMode() → {String}

returns the current blend mode for this renderer

Returns:
String -

blend mode

getBounds() → {me.Rect}

returns the bounds (size and position) of the parent container

Returns:
me.Rect

getCanvas() → {HTMLCanvasElement}

return a reference to the system canvas

Returns:
HTMLCanvasElement

getColor(current)

get the current fill & stroke style color.

Parameters:
Name Type Description
current me.Color

global color

getContext2d(canvas, transparentopt) → {Context2d}

Returns the 2D Context object of the given Canvas
Also configures anti-aliasing and blend modes based on constructor options.

Parameters:
Name Type Attributes Default Description
canvas HTMLCanvasElement
transparent Boolean <optional>
true

use false to disable transparency

Returns:
Context2d

getHeight() → {Number}

return the height of the system Canvas

Returns:
Number

getScreenCanvas() → {HTMLCanvasElement}

return a reference to the screen canvas

Returns:
HTMLCanvasElement

getScreenContext() → {Context2d}

return a reference to the screen canvas corresponding 2d Context
(will return buffered context if double buffering is enabled, or a reference to the Screen Context)

Returns:
Context2d

getWidth() → {Number}

return the width of the system Canvas

Returns:
Number

globalAlpha() → {Number}

return the current global alpha

Returns:
Number

overlaps(rect) → {boolean}

check if the given rectangle overlaps with the renderer screen coordinates

Parameters:
Name Type Description
rect me.Rect
Returns:
boolean -

true if overlaps

reset()

Reset context state

resize(width, height)

resizes the system canvas

Parameters:
Name Type Description
width Number

new width of the canvas

height Number

new height of the canvas

setAntiAlias(context, enableopt)

enable/disable image smoothing (scaling interpolation) for the given context

Parameters:
Name Type Attributes Default Description
context Context2d
enable Boolean <optional>
false

setMask(maskopt)

A mask limits rendering elements to the shape and position of the given mask object. So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible. Mask are not preserved through renderer context save and restore.

Parameters:
Name Type Attributes Description
mask me.Rect | me.Polygon | me.Line | me.Ellipse <optional>

the shape defining the mask to be applied

setTint(tintopt)

set a rendering tint (WebGL only) for sprite based renderables.

Parameters:
Name Type Attributes Description
tint me.Color <optional>

the tint color

stroke(shape)

stroke the given shape

Parameters:
Name Type Description
shape me.Rect | me.Polygon | me.Line | me.Ellipse

a shape object to stroke

updateBounds()

update the bounds (size and position) of the parent container. (this can be manually called in case of manual page layout modification not triggering a resize event)