Members
bounds Bounds
Gets the bounds of the path.
shapePrimitives { shape : ShapePrimitive, transform? : Matrix }[]
The list of shape primitives that make up the path.
Methods
Adds another path to the current path. This method allows for the combination of multiple paths into one.
Name | Type | Attributes | Description |
---|---|---|---|
path |
GraphicsPath |
The |
|
transform |
Matrix |
<optional> |
An optional |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Adds an arc to the path. The arc is centered at (x, y)
position with radius radius
starting at startAngle
and ending at endAngle
.
Name | Type | Description |
---|---|---|
x |
number |
The x-coordinate of the arc's center. |
y |
number |
The y-coordinate of the arc's center. |
radius |
number |
The radius of the arc. |
startAngle |
number |
The starting angle of the arc, in radians. |
endAngle |
number |
The ending angle of the arc, in radians. |
counterclockwise |
boolean |
Specifies whether the arc should be drawn in the anticlockwise direction. False by default. |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Adds an arc to the path with the arc tangent to the line joining two specified points.
The arc radius is specified by radius
.
Name | Type | Description |
---|---|---|
x1 |
number |
The x-coordinate of the first point. |
y1 |
number |
The y-coordinate of the first point. |
x2 |
number |
The x-coordinate of the second point. |
y2 |
number |
The y-coordinate of the second point. |
radius |
number |
The radius of the arc. |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Adds an SVG-style arc to the path, allowing for elliptical arcs based on the SVG spec.
Name | Type | Description |
---|---|---|
rx |
number |
The x-radius of the ellipse. |
ry |
number |
The y-radius of the ellipse. |
xAxisRotation |
number |
The rotation of the ellipse's x-axis relative to the x-axis of the coordinate system, in degrees. |
largeArcFlag |
number |
Determines if the arc should be greater than or less than 180 degrees. |
sweepFlag |
number |
Determines if the arc should be swept in a positive angle direction. |
x |
number |
The x-coordinate of the arc's end point. |
y |
number |
The y-coordinate of the arc's end point. |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Adds a cubic Bezier curve to the path. It requires three points: the first two are control points and the third one is the end point. The starting point is the last point in the current path.
Name | Type | Attributes | Description |
---|---|---|---|
cp1x |
number |
The x-coordinate of the first control point. |
|
cp1y |
number |
The y-coordinate of the first control point. |
|
cp2x |
number |
The x-coordinate of the second control point. |
|
cp2y |
number |
The y-coordinate of the second control point. |
|
x |
number |
The x-coordinate of the end point. |
|
y |
number |
The y-coordinate of the end point. |
|
smoothness |
number |
<optional> |
Optional parameter to adjust the smoothness of the curve. |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Builds the path.
Draw Rectangle with chamfer corners. These are angled corners.
Name | Type | Attributes | Description |
---|---|---|---|
x |
number |
Upper left corner of rect |
|
y |
number |
Upper right corner of rect |
|
width |
number |
Width of rect |
|
height |
number |
Height of rect |
|
chamfer |
number |
non-zero real number, size of corner cutout |
|
transform |
Matrix |
<optional> |
Returns:
Type | Description |
---|---|
this |
Draws a circle shape. This method adds a new circle path to the current drawing.
Name | Type | Attributes | Description |
---|---|---|---|
x |
number |
The x-coordinate of the center of the circle. |
|
y |
number |
The y-coordinate of the center of the circle. |
|
radius |
number |
The radius of the circle. |
|
transform |
Matrix |
<optional> |
An optional |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Closes the current path by drawing a straight line back to the start. If the shape is already closed or there are no points in the path, this method does nothing.
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Draws a given shape on the canvas.
This is a generic method that can draw any type of shape specified by the ShapePrimitive
parameter.
An optional transformation matrix can be applied to the shape, allowing for complex transformations.
Name | Type | Attributes | Description |
---|---|---|---|
shape |
ShapePrimitive |
The shape to draw, defined as a |
|
matrix |
Matrix |
<optional> |
An optional |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Draws an ellipse at the specified location and with the given x and y radii. An optional transformation can be applied, allowing for rotation, scaling, and translation.
Name | Type | Attributes | Description |
---|---|---|---|
x |
number |
The x-coordinate of the center of the ellipse. |
|
y |
number |
The y-coordinate of the center of the ellipse. |
|
radiusX |
number |
The horizontal radius of the ellipse. |
|
radiusY |
number |
The vertical radius of the ellipse. |
|
transform |
Matrix |
<optional> |
An optional |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Ends the current polygon path. If closePath
is set to true,
the path is closed by connecting the last point to the first one.
This method finalizes the current polygon and prepares it for drawing or adding to the shape primitives.
Name | Type | Default | Description |
---|---|---|---|
closePath |
boolean | false |
A boolean indicating whether to close the polygon by connecting the last point back to the starting point. False by default. |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Draw Rectangle with fillet corners. This is much like rounded rectangle however it support negative numbers as well for the corner radius.
Name | Type | Description |
---|---|---|
x |
number |
Upper left corner of rect |
y |
number |
Upper right corner of rect |
width |
number |
Width of rect |
height |
number |
Height of rect |
fillet |
number |
accept negative or positive values |
Returns:
Type | Description |
---|---|
this |
Finalizes the drawing of the current path. Optionally, it can close the path.
Name | Type | Default | Description |
---|---|---|---|
closePath |
boolean | false |
A boolean indicating whether to close the path after finishing. False by default. |
Connects the current point to a new point with a straight line. This method updates the current path.
Name | Type | Description |
---|---|---|
x |
number |
The x-coordinate of the new point to connect to. |
y |
number |
The y-coordinate of the new point to connect to. |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Sets the starting point for a new sub-path. Any subsequent drawing commands are considered part of this path.
Name | Type | Description |
---|---|---|
x |
number |
The x-coordinate for the starting point. |
y |
number |
The y-coordinate for the starting point. |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Draws a polygon shape. This method allows for the creation of complex polygons by specifying a sequence of points.
Name | Type | Attributes | Description |
---|---|---|---|
points |
number[] | PointData[] |
An array of numbers, or or an array of PointData objects eg [{x,y}, {x,y}, {x,y}] representing the x and y coordinates of the polygon's vertices, in sequence. |
|
close |
boolean |
<optional> |
A boolean indicating whether to close the polygon path. True by default. |
transform |
Matrix |
<optional> |
An optional |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Adds a quadratic curve to the path. It requires two points: the control point and the end point. The starting point is the last point in the current path.
Name | Type | Attributes | Description |
---|---|---|---|
cp1x |
number |
The x-coordinate of the control point. |
|
cp1y |
number |
The y-coordinate of the control point. |
|
x |
number |
The x-coordinate of the end point. |
|
y |
number |
The y-coordinate of the end point. |
|
smoothing |
number |
<optional> |
Optional parameter to adjust the smoothness of the curve. |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Draws a rectangle shape. This method adds a new rectangle path to the current drawing.
Name | Type | Attributes | Description |
---|---|---|---|
x |
number |
The x-coordinate of the top-left corner of the rectangle. |
|
y |
number |
The y-coordinate of the top-left corner of the rectangle. |
|
w |
number |
The width of the rectangle. |
|
h |
number |
The height of the rectangle. |
|
transform |
Matrix |
<optional> |
An optional |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Draws a regular polygon with a specified number of sides. All sides and angles are equal.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
number |
The x-coordinate of the center of the polygon. |
||
y |
number |
The y-coordinate of the center of the polygon. |
||
radius |
number |
The radius of the circumscribed circle of the polygon. |
||
sides |
number |
The number of sides of the polygon. Must be 3 or more. |
||
rotation |
number | 0 |
The rotation angle of the polygon, in radians. Zero by default. |
|
transform |
Matrix |
<optional> |
An optional |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Draws a polygon with rounded corners.
Similar to regularPoly
but with the ability to round the corners of the polygon.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
number |
The x-coordinate of the center of the polygon. |
||
y |
number |
The y-coordinate of the center of the polygon. |
||
radius |
number |
The radius of the circumscribed circle of the polygon. |
||
sides |
number |
The number of sides of the polygon. Must be 3 or more. |
||
corner |
number |
The radius of the rounding of the corners. |
||
rotation |
number | 0 |
The rotation angle of the polygon, in radians. Zero by default. |
|
smoothness |
number |
<optional> |
Optional parameter to adjust the smoothness of the rounding. |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Draws a rectangle with rounded corners. The corner radius can be specified to determine how rounded the corners should be. An optional transformation can be applied, which allows for rotation, scaling, and translation of the rectangle.
Name | Type | Attributes | Description |
---|---|---|---|
x |
number |
The x-coordinate of the top-left corner of the rectangle. |
|
y |
number |
The y-coordinate of the top-left corner of the rectangle. |
|
w |
number |
The width of the rectangle. |
|
h |
number |
The height of the rectangle. |
|
radius |
number |
<optional> |
The radius of the rectangle's corners. If not specified, corners will be sharp. |
transform |
Matrix |
<optional> |
An optional |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Draws a shape with rounded corners. This function supports custom radius for each corner of the shape. Optionally, corners can be rounded using a quadratic curve instead of an arc, providing a different aesthetic.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
points |
RoundedPoint[] |
An array of |
||
radius |
number |
The default radius for the corners.
This radius is applied to all corners unless overridden in |
||
useQuadratic |
boolean | false |
If set to true, rounded corners are drawn using a quadraticCurve method instead of an arc method. Defaults to false. |
|
smoothness |
number |
<optional> |
Specifies the smoothness of the curve when |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |
Starts a new polygon path from the specified starting point. This method initializes a new polygon or ends the current one if it exists.
Name | Type | Description |
---|---|---|
x |
number |
The x-coordinate of the starting point of the new polygon. |
y |
number |
The y-coordinate of the starting point of the new polygon. |
Returns:
Type | Description |
---|---|
this | The instance of the current object for chaining. |