API Docs for: 1.0.0
Show:

Canvas.Context2d Class

Wrapper for a canvas 2d context. It exposes the exact same api as the native 2d context, plus some extras, documented below. Just like Y.Node, use get() and set() to modify attributes.

Constructor

Canvas.Context2d

(
  • node
  • config
)

Parameters:

  • node Y.Node

    the canvas element

  • config Object
    • pixelAlign=true Boolean

      Pass true to get thinner, cleaner strokes. Pass false to get the default rendering.

Item Index

Methods

get

(
  • name
)
Mixed

Get an attribute. This accepts all attributes of the context and the special name "pixelAlign".

Parameters:

  • name String

    the attribute name

Returns:

Mixed:

the attribute value

line

(
  • dx
  • dy
)

Move relative to the current pen location. This only works when the transformation matrix is constant!

Parameters:

  • dx Int
  • dy Int

move

(
  • dx
  • dy
)

Move relative to the current pen location (set via moveTo or move). This only works when the transformation matrix is constant!

Parameters:

  • dx Int
  • dy Int

poly

(
  • list
)

Draw a polygon from a set of deltas.

Parameters:

  • list Array

    List of deltas (dx,dy). You can omit values that are zero.

roundedRect

(
  • top
  • left
  • bottom
  • right
  • radius
)

Define a rectangle with rounded corners. You must call stroke(), fill(), etc. afterwards.

Parameters:

  • top Int
  • left Int
  • bottom Int
  • right Int
  • radius Int

    radius of rounded corners

set

(
  • name
  • value
)

Set an attribute. This accepts all attributes of the context and the special name "pixelAlign".

Parameters:

  • name String

    the attribute name

  • value Mixed

    the attribute value