Class Renderer

a base renderer object

Hierarchy (view full)

Constructors

Properties

currentColor: Color
currentTint: Color
depthTest: string

the default method to sort object ("sorting", "z-buffer")

"sorting"
designRatio: number

the requested video size ratio

isContextValid: boolean

true if the current rendering context is valid

true
path2D: Path2D

The Path2D instance used by the renderer to draw primitives

projectionMatrix: Matrix3d
renderTarget: CanvasRenderTarget

The renderer renderTarget

renderTarget

scaleRatio: Vector2d

the scaling ratio to be applied to the main canvas

<1,1>
settings: object

The given constructor options

type: string

The renderer type : Canvas, WebGL, etc... (override this property with a specific value when implementing a custom renderer)

uvOffset: number

Accessors

  • get height(): number
  • return the height of the canvas which this renderer draws to

    Returns number

    height of the system Canvas

  • set height(value): void
  • Parameters

    • value: number

    Returns void

Methods

  • disable (remove) the rendering mask set through setMask.

    Returns void

    Renderer#setMask

  • clear the rendering tint set through setTint.

    Returns void

    Renderer#setTint

  • returns the current blend mode for this renderer

    Returns string

    blend mode

  • return a reference to the current render target corresponding canvas which this renderer draws to

    Returns HTMLCanvasElement

  • return a reference to the current render target corresponding Context

    Returns CanvasRenderingContext2D | WebGLRenderingContext

  • check if the given rect or bounds overlaps with the renderer screen coordinates

    Parameters

    Returns boolean

    true if overlaps

  • resizes the system canvas

    Parameters

    • width: number

      new width of the canvas

    • height: number

      new height of the canvas

    Returns void

  • enable/disable image smoothing (scaling interpolation) for the current render target

    Parameters

    • Optionalenable: boolean = false

    Returns void

  • 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.

    Returns void

  • set a coloring tint for sprite based renderables

    Parameters

    • tint: Color

      the tint color

    • Optionalalpha: number = tint.alpha

      an alpha value to be applied to the tint

    Returns void

  • stroke the given shape

    Parameters

    • shape:
          | Rect
          | Polygon
          | Line
          | Ellipse
          | RoundRect

      a shape object to stroke

    • Optionalfill: boolean

      fill the shape with the current color if true

    Returns void

  • tint the given image or canvas using the given color

    Parameters

    • src: OffscreenCanvas | HTMLCanvasElement | HTMLImageElement

      the source image to be tinted

    • color: string | Color

      the color that will be used to tint the image

    • Optionalmode: string = "multiply"

      the composition mode used to tint the image

    Returns OffscreenCanvas | HTMLCanvasElement

    a new canvas or offscreencanvas (if supported) element representing the tinted image

  • creates a Blob object representing the last rendered frame

    Parameters

    • Optionaltype: string = "image/png"

      A string indicating the image format

    • Optionalquality: number

      A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.

    Returns Promise<any>

    A Promise returning a Blob object representing the last rendered frame

    renderer.convertToBlob().then((blob) => console.log(blob));
    
  • returns a data URL containing a representation of the last frame rendered

    Parameters

    • Optionaltype: string = "image/png"

      A string indicating the image format

    • Optionalquality: number

      A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.

    Returns Promise<any>

    A Promise returning a string containing the requested data URL.

    renderer.toDataURL().then((dataURL) => console.log(dataURL));
    
  • creates an ImageBitmap object of the last frame rendered (not supported by standard Canvas)

    Parameters

    • Optionaltype: string = "image/png"

      A string indicating the image format

    • Optionalquality: number

      A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.

    Returns Promise<any>

    A Promise returning an ImageBitmap.

    renderer.transferToImageBitmap().then((image) => console.log(image));