Class Fz2D.Canvas

Defined in: src/renderer/canvas.coffee

Overview

Public: Canvas (2D)

Subclasses

Fz2D.CanvasWebGL

Class Method Summary

Instance Method Summary

Class Method Details

.getContext(w, h, color = null, selector = null, type = @supported, opts = @opts) Source

Public: Requests and configures a context. w - width h - height color - background color (optional) selector - selector to find or create the canvas for the context (optional) type - type of the context (default: supported) opts - options to pass to when requesting the context (optional) Returns the requested context or null.

Parameters:

  • wwidth
  • hheight
  • colorbackground color (optional)
  • selectorselector to find or create the canvas for the context (optional)
  • typetype of the context (default: supported)
  • optsoptions to pass to when requesting the context (optional)

Returns:

  • Returns the requested context or null.

Constructor Details

::constructor(w, h, color = null, selector = null) Source

Public: Constructor. w - width h - height color - background HTML color code (default: Fz2D.BG) selector - query selector or id (default: Fz2D.SELECTOR)

Parameters:

  • wwidth
  • hheight
  • colorbackground HTML color code (default: Fz2D.BG)
  • selectorquery selector or id (default: Fz2D.SELECTOR)

Instance Method Details

::clear() Source

Public: Clears the canvas.

::draw(texture, sx, sy, sw, sh, x, y, w, h, hw, hh, angle, alpha) Source

Public: Draws a Fz2D.Texture. texture - Fz2D.Texture sx - source position on the X axis sy - source position on the Y axis sw - source width sh - source height x - desired position on the X axis y - desired position on the Y axis w - desired width h - desired height hw - desired half width hh - desired half height angle - rotation angle alpha - alpha value

Parameters:

  • (Fz2D.Texture) textureFz2D.Texture
  • sxsource position on the X axis
  • sysource position on the Y axis
  • swsource width
  • shsource height
  • xdesired position on the X axis
  • ydesired position on the Y axis
  • wdesired width
  • hdesired height
  • hwdesired half width
  • hhdesired half height
  • anglerotation angle
  • alphaalpha value

::fill(color) Source

Public: Fills the canvas with a solid color. color - HTML color code

Parameters:

  • colorHTML color code

::flush() Source

Public: Flushes the canvas.

::toElement() Source

Public: Returns the canvas as an HTML DOM element.

::toImage() Source

Public: Returns the canvas as an image.