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.Nodethe canvas element
-
config
Object-
pixelAlign=true
BooleanPass true to get thinner, cleaner strokes. Pass false to get the default rendering.
-
Methods
get
-
name
Get an attribute. This accepts all attributes of the context and the special name "pixelAlign".
Parameters:
-
name
Stringthe attribute name
Returns:
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
ArrayList 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
Intradius of rounded corners
set
-
name
-
value
Set an attribute. This accepts all attributes of the context and the special name "pixelAlign".
Parameters:
-
name
Stringthe attribute name
-
value
Mixedthe attribute value