CanvasDrawing Class
Canvas implementation of the Drawing class.
CanvasDrawing is not intended to be used directly. Instead, use the Drawing class.
If the browser lacks SVG capabilities but has
Canvas capabilities, the Drawing
class will point to the CanvasDrawing class.
Item Index
Methods
Properties
Methods
_clearAndUpdateCoords
()
private
Clears the coordinate arrays. Called at the end of a drawing operation.
_createGraphic
()
private
Creates canvas element
Returns:
_getLinearGradient
()
private
Returns a linear gradient fill
Returns:
_getRadialGradient
()
private
Returns a radial gradient fill
Returns:
_initProps
()
private
Clears all values
_toRGBA
-
val -
alpha
Parses hex color string and alpha value to rgba
_trackSize
-
w -
h
Updates the size of the graphics object
_updateCoords
-
x -
y
Tracks coordinates. Used to calculate the start point of dashed lines.
_updateDrawingQueue
-
val
Queues up a method to be executed when a shape redraws.
Parameters:
-
valArrayAn array containing data that can be parsed into a method and arguments. The value at zero-index of the array is a string reference of the drawing method that will be called. All subsequent indices are argument for that method. For example,
lineTo(10, 100)would be structured as:["lineTo", 10, 100].
_updateNodePosition
()
private
Moves the shape's dom node.
clear
()
Clears the graphics object.
closePath
()
Ends a fill and stroke
curveTo
-
cp1x -
cp1y -
cp2x -
cp2y -
x -
y
Draws a bezier curve.
Parameters:
drawCircle
-
x -
y -
r
Draws a circle. Used internally by CanvasCircle class.
drawDiamond
-
x -
y -
width -
height
Draws a diamond.
drawEllipse
-
x -
y -
w -
h
Draws an ellipse. Used internally by CanvasEllipse class.
drawRect
-
x -
y -
w -
h -
ew -
eh
Draws a rectangle with rounded corners.
drawRect
-
x -
y -
w -
h
Draws a rectangle.
drawWedge
-
x -
y -
startAngle -
arc -
radius -
yRadius
Draws a wedge.
Parameters:
-
xNumberx-coordinate of the wedge's center point
-
yNumbery-coordinate of the wedge's center point
-
startAngleNumberstarting angle in degrees
-
arcNumbersweep of the wedge. Negative values draw clockwise.
-
radiusNumberradius of wedge. If [optional] yRadius is defined, then radius is the x radius.
-
yRadiusNumber[optional] y radius for wedge.
end
()
Completes a drawing operation.
lineTo
-
point1 -
point2
Draws a line segment using the current line style from the current drawing position to the specified x and y coordinates.
moveTo
-
x -
y
Moves the current drawing position to specified x and y coordinates.
quadraticCurveTo
-
cpx -
cpy -
x -
y
Draws a quadratic bezier curve.
