new CanvasHelper(canvas)
A wrapper helper for drawing to HTML canvases.
Parameters:
| Name | Type | Description |
|---|---|---|
canvas |
HTMLCanvasElement | CanvasRenderingContext2D | The canvas or canvas context to draw to |
Methods
-
clear()
-
Clears the canvas.
Returns:
The current instance- Type
- CanvasHelper
-
drawCircle(rect [, drawingParameters])
-
Draws a circle in the provided rectangle on the canvas.
Parameters:
Name Type Argument Description rectCore.Math.Rect The rect where the circle will be drawn drawingParametersobject <optional>
Additional drawing parameters. Values are acceptable HTML canvas values Properties
Name Type Argument Description fillColorCore.Annotations.Color <optional>
Fill color borderColorCore.Annotations.Color <optional>
Border or stroke color borderStylestring <optional>
Either 'solid' or 'dash'. Default: solid borderWidthnumber <optional>
The border width dashesArray.<number> <optional>
Array of dash size and spacing ex. [4, 3]. Default: [3] opacitynumber <optional>
Opacity value. Default: 1 clipPathboolean <optional>
Whether to clip the path. Default: false transformCore.Math.Matrix <optional>
Drawing transformation isStatefulboolean <optional>
Whether to undo canvas context changes after rendering. Default: true Returns:
The current instance- Type
- CanvasHelper
-
drawCircleXY(cx, cy, radius [, drawingParameters])
-
Draws a circle in the provided rectangle on the canvas.
Parameters:
Name Type Argument Description cxnumber The x-coordinate of the circles center cynumber The rect where the circle will be drawn radiusnumber The radius of the circle drawingParametersobject <optional>
Additional drawing parameters. Values are acceptable HTML canvas values Properties
Name Type Argument Description fillColorCore.Annotations.Color <optional>
Fill color borderColorCore.Annotations.Color <optional>
Border or stroke color borderStylestring <optional>
Either 'solid' or 'dash'. Default: solid borderWidthnumber <optional>
The border width dashesArray.<number> <optional>
Array of dash size and spacing ex. [4, 3]. Default: [3] opacitynumber <optional>
Opacity value. Default: 1 clipPathboolean <optional>
Whether to clip the path. Default: false transformCore.Math.Matrix <optional>
Drawing transformation isStatefulboolean <optional>
Whether to undo canvas context changes after rendering. Default: true Returns:
The current instance- Type
- CanvasHelper
-
drawClouds(annot, points [, drawingParameters])
-
Draws a cloud shape provided by the points on the canvas.
Parameters:
Name Type Argument Description annotCore.Annotations.Annotation The annotation being drawn pointsArray.<Core.Math.Point> An array of points that represents a shape drawingParametersobject <optional>
Additional drawing parameters. Values are acceptable HTML canvas values Properties
Name Type Argument Description fillColorCore.Annotations.Color <optional>
Fill color borderColorCore.Annotations.Color <optional>
Border or stroke color borderStylestring <optional>
Either 'solid' or 'dash'. Default: solid borderWidthnumber <optional>
The border width dashesArray.<number> <optional>
Array of dash size and spacing ex. [4, 3]. Default: [3] opacitynumber <optional>
Opacity value. Default: 1 closePathboolean <optional>
Whether automatically close the path between the first and last points. Default: true clipPathboolean <optional>
Whether to clip the path. Default: false transformCore.Math.Matrix <optional>
Drawing transformation isStatefulboolean <optional>
Whether to undo canvas context changes after rendering. Default: true Returns:
The current instance- Type
- CanvasHelper
-
drawLine(start, end [, drawingParameters])
-
Draws a line using two points on the canvas.
Parameters:
Name Type Argument Description startCore.Math.Point The start point endCore.Math.Point The end point drawingParametersobject <optional>
Additional drawing parameters. Values are acceptable HTML canvas values Properties
Name Type Argument Description colorCore.Annotations.Color <optional>
The line color borderStylestring <optional>
Either 'solid' or 'dash'. Default: solid borderWidthnumber <optional>
The border width dashesArray.<number> <optional>
Array of dash size and spacing ex. [4, 3]. Default: [3] transformCore.Math.Matrix <optional>
Drawing transformation isStatefulboolean <optional>
Whether to undo canvas context changes after rendering. Default: true Returns:
The current instance- Type
- CanvasHelper
-
drawLineXY(sx, sy, dx, dy [, drawingParameters])
-
Draws a line using two points on the canvas.
Parameters:
Name Type Argument Description sxnumber The start x-coordinate synumber The start y-coordinate dxnumber The end x-coordinate dynumber The end y-coordinate drawingParametersobject <optional>
Additional drawing parameters. Values are acceptable HTML canvas values Properties
Name Type Argument Description colorCore.Annotations.Color <optional>
The line color borderStylestring <optional>
Either 'solid' or 'dash'. Default: solid borderWidthnumber <optional>
The border width dashesArray.<number> <optional>
Array of dash size and spacing ex. [4, 3]. Default: [3] transformCore.Math.Matrix <optional>
Drawing transformation isStatefulboolean <optional>
Whether to undo canvas context changes after rendering. Default: true Returns:
The current instance- Type
- CanvasHelper
-
drawPolygon(points [, drawingParameters])
-
Draws a shape provided by the points on the canvas.
Parameters:
Name Type Argument Description pointsArray.<Core.Math.Point> An array of points that represents a shape drawingParametersobject <optional>
Additional drawing parameters. Values are acceptable HTML canvas values Properties
Name Type Argument Description fillColorCore.Annotations.Color <optional>
Fill color borderColorCore.Annotations.Color <optional>
Border or stroke color borderStylestring <optional>
Either 'solid' or 'dash'. Default: solid borderWidthnumber <optional>
The border width dashesArray.<number> <optional>
Array of dash size and spacing ex. [4, 3]. Default: [3] opacitynumber <optional>
Opacity value. Default: 1 closePathboolean <optional>
Whether automatically close the path between the first and last points. Default: true clipPathboolean <optional>
Whether to clip the path. Default: false transformCore.Math.Matrix <optional>
Drawing transformation isStatefulboolean <optional>
Whether to undo canvas context changes after rendering. Default: true Returns:
The current instance- Type
- CanvasHelper
-
drawRectangle(rect [, drawingParameters])
-
Draws the rectangle to a location on the canvas.
Parameters:
Name Type Argument Description rectCore.Math.Rect The rect to be drawn drawingParametersobject <optional>
Additional drawing parameters. Values are acceptable HTML canvas values Properties
Name Type Argument Description fillColorCore.Annotations.Color <optional>
Fill color borderColorCore.Annotations.Color <optional>
Border or stroke color borderStylestring <optional>
Either 'solid' or 'dash'. Default: solid borderWidthnumber <optional>
The border width dashesArray.<number> <optional>
Array of dash size and spacing ex. [4, 3]. Default: [3] opacitynumber <optional>
Opacity value. Default: 1 clipPathboolean <optional>
Whether to clip the path. Default: false transformCore.Math.Matrix <optional>
Drawing transformation isStatefulboolean <optional>
Whether to undo canvas context changes after rendering. Default: true Returns:
The current instance- Type
- CanvasHelper
-
drawText(text, x, y [, drawingParameters])
-
Draws the text to a location on the canvas.
Parameters:
Name Type Argument Description textstring The text to be drawn xnumber The x-coordinate ynumber The y-coordinate drawingParametersobject <optional>
Additional drawing parameters. Values are acceptable HTML canvas values Properties
Name Type Argument Description fillColorCore.Annotations.Color <optional>
Fill color borderColorCore.Annotations.Color <optional>
Border or stroke color borderStylestring <optional>
Either 'solid' or 'dash'. Default: solid borderWidthnumber <optional>
The border width dashesArray.<number> <optional>
Array of dash size and spacing ex. [4, 3]. Default: [3] fontSizenumber <optional>
Size of font. Default: 10 fontSizeUnitsstring <optional>
Font units. Default: pt fontWeightstring <optional>
Font boldness. Default: normal fontStylestring <optional>
Font style. Default: normal fontFamilystring <optional>
List of font-families. Default: sans-serif opacitynumber <optional>
Opacity value. Default: 1 transformCore.Math.Matrix <optional>
Drawing transformation isStatefulboolean <optional>
Whether to undo canvas context changes after rendering. Default: true Returns:
The current instance- Type
- CanvasHelper
-
measureText(text [, options])
-
Measures the width of the text given the string and additional information.
Parameters:
Name Type Argument Description textstring The text to be drawn optionsobject <optional>
Additional drawing parameters. Values are acceptable HTML canvas values Properties
Name Type Argument Description fontSizenumber <optional>
Size of font. Default: 10 fontSizeUnitsstring <optional>
Font units. Default: pt fontWeightstring <optional>
Font boldness. Default: normal fontStylestring <optional>
Font style. Default: normal fontFamilystring <optional>
List of font-families. Default: sans-serif Returns:
The measured text info- Type
- TextMetrics