class
Graphics
Draw on an HTML5 canvas.
This class wraps an HTML5 Canvas and 2D rendering context in a slightly higher-level API, while also allowing to register hit regions.
- Properties
- canvas, ctx, height, hitCanvas, hitCtx, width
- Methods
- constructor, addHitRegion, clearHitCanvas, copy, createChild, fillCanvas, fillEllipse, fillPath, fillRect, fillText, measureText, resize, strokeEllipse, strokePath, strokeRect
Properties
- canvasget
- Type:
-
HTMLCanvasElement
- ctxget
Native draw context for the HTML5 Canvas.
Can be used to draw directly without using any convenience API.
- Type:
-
CanvasRenderingContext2D
- heightget
Returns the CSS height.
- Type:
-
number
- hitCanvasget
Manages hit regions which connects DOM interactions to the Canvas.
- Type:
-
HitCanvas
- hitCtxget
Draw context matching the hit canvas.
- Type:
-
CanvasRenderingContext2D
- widthget
Returns the CSS width.
- Type:
-
number
Methods
- constructor(canvas, hitCanvas?)
- Parameters:
-
-
HTMLCanvasElement
canvas -
HitCanvas
hitCanvas
-
- addHitRegion(region)
- Parameters:
-
-
HitRegionSpecification
region
-
- Return type:
HitRegionBuilder
- clearHitCanvas()
- Return type:
void
- copy(g, dx, dy)
- Parameters:
-
-
Graphics
g -
number
dx -
number
dy
-
- Return type:
void
- createChild(width, height)
- Parameters:
-
-
number
width -
number
height
-
- Return type:
Graphics
- fillCanvas(fill)
- Parameters:
-
-
FillStyle
fill
-
- Return type:
void
- fillEllipse(fill)
- Parameters:
-
-
EllipseFill
fill
-
- Return type:
void
- fillPath(fill)
- Parameters:
-
-
PathFill
fill
-
- Return type:
void
- fillRect(fill)
- Parameters:
-
-
RectFill
fill
-
- Return type:
void
- fillText(fill)
- Parameters:
-
-
TextFill
fill
-
- Return type:
void
- measureText(text, font)
- Parameters:
-
-
string
text -
string
font
-
- Return type:
TextMetrics
- resize(width, height)
- Parameters:
-
-
number
width -
number
height
-
- Return type:
void
- strokeEllipse(stroke)
- Parameters:
-
-
EllipseStroke
stroke
-
- Return type:
void
- strokePath(stroke)
- Parameters:
-
-
PathStroke
stroke
-
- Return type:
void
- strokeRect(stroke)
- Parameters:
-
-
RectStroke
stroke
-
- Return type:
void