Class CanvasDrawingUtil
Set of drawing apis for canvas based classes.
Properties
_reHex
- private object
Regex expression used for converting hex strings to rgb
Methods
private
void
_2RGB
(
)
Converts color to rgb format
private
void
_2RGBA
(
)
Parses hex color string and alpha value to rgba
private
void
_createDummy
(
)
Creates dom element used for converting color string to rgb
private
void
_createGraphic
(
)
Creates canvas element
private
void
_draw
(
)
Completes a shape or drawing
private
void
_getFill
(
)
Returns ths actual fill object to be used in a drawing or shape
private
void
_getLinearGradient
(
)
Returns a linear gradient fill
private
void
_getRadialGradient
(
)
Returns a radial gradient fill
private
void
_initProps
(
)
Clears all values
private
void
_trackPos
(
x
,
y
)
Updates the position of the current drawing
- Parameters:
-
x
<Number>
x-coordinate
-
y
<Number>
y-coordinate
private
void
_trackSize
(
w
,
h
)
Updates the size of the graphics object
- Parameters:
-
w
<Number>
width
-
h
<Number>
height
private
void
_updateShapeProps
(
x
,
y
)
Updates the position and size of the current drawing
- Parameters:
-
x
<Number>
x-coordinate
-
y
<Number>
y-coordinate
void
beginBitmapFill
(
config
)
Specifies a bitmap fill used by subsequent calls to other drawing methods.
- Parameters:
-
config
<Object>
void
beginFill
(
color
,
alpha
)
Specifes a solid fill used by subsequent calls to other drawing methods.
- Parameters:
-
color
<String>
Hex color value for the fill.
-
alpha
<Number>
Value between 0 and 1 used to specify the opacity of the fill.
void
beginGradientFill
(
config
)
Specifies a gradient fill used by subsequent calls to other drawing methods.
- Parameters:
-
config
<Object>
void
clear
(
)
Clears the graphics object.
void
curveTo
(
cp1x
,
cp1y
,
cp2x
,
cp2y
,
x
,
y
)
Draws a bezier curve.
- Parameters:
-
cp1x
<Number>
x-coordinate for the first control point.
-
cp1y
<Number>
y-coordinate for the first control point.
-
cp2x
<Number>
x-coordinate for the second control point.
-
cp2y
<Number>
y-coordinate for the second control point.
-
x
<Number>
x-coordinate for the end point.
-
y
<Number>
y-coordinate for the end point.
void
drawCircle
(
x
,
y
,
r
)
Draws a circle.
- Parameters:
-
x
<Number>
y-coordinate
-
y
<Number>
x-coordinate
-
r
<Number>
radius
void
drawEllipse
(
x
,
y
,
w
,
h
)
Draws an ellipse.
- Parameters:
-
x
<Number>
x-coordinate
-
y
<Number>
y-coordinate
-
w
<Number>
width
-
h
<Number>
height
void
drawRect
(
x
,
y
,
w
,
h
)
Draws a rectangle.
- Parameters:
-
x
<Number>
x-coordinate
-
y
<Number>
y-coordinate
-
w
<Number>
width
-
h
<Number>
height
private
void
drawWedge
(
x
,
y
,
startAngle
,
arc
,
radius
,
yRadius
)
Draws a wedge.
- Parameters:
-
x
<object>
x component of the wedge's center point
-
y
<object>
y component of the wedge's center point
-
startAngle
<object>
starting angle in degrees
-
arc
<object>
sweep of the wedge. Negative values draw clockwise.
-
radius
<object>
radius of wedge. If [optional] yRadius is defined, then radius is the x radius.
-
yRadius
<object>
[optional] y radius for wedge.
void
end
(
)
Completes a drawing operation.
getShape
(
config
)
Creates a Shape instance and adds it to the graphics object.
- Parameters:
-
config
<Object>
Object literal of properties used to construct a Shape.
- Returns:
- Shape
private
void
initializer
(
)
Initializes the class.
private
void
lineGradientStyle
(
)
Not implemented
Specifies a gradient to use for the stroke when drawing lines.
void
lineStyle
(
thickness
,
color
,
alpha
)
Specifies a line style used for subsequent calls to drawing methods.
- Parameters:
-
thickness
<Number>
indicates the thickness of the line
-
color
<String>
hex color value for the line
-
alpha
<Number>
Value between 0 and 1 used to specify the opacity of the fill.
void
lineTo
(
point1
,
point2
)
Draws a line segment using the current line style from the current drawing position to the specified x and y coordinates.
- Parameters:
-
point1
<Number>
x-coordinate for the end point.
-
point2
<Number>
y-coordinate for the end point.
void
moveTo
(
x
,
y
)
Moves the current drawing position to specified x and y coordinates.
- Parameters:
-
x
<Number>
x-coordinate for the end point.
-
y
<Number>
y-coordinate for the end point.
void
quadraticCurveTo
(
cpx
,
cpy
,
x
,
y
)
Draws a quadratic bezier curve.
- Parameters:
-
cpx
<Number>
x-coordinate for the control point.
-
cpy
<Number>
y-coordinate for the control point.
-
x
<Number>
x-coordinate for the end point.
-
y
<Number>
y-coordinate for the end point.
void
setSize
(
w
,
h
)
Sets the size of the graphics object.
- Parameters:
-
w
<Number>
width to set for the instance.
-
h
<Number>
height to set for the instance.