AnyChart
API Reference
Still have questions?
Contact support
Top
You are looking at an outdated v7 version of this document. Switch to the v8 version to see the up to date information.

class anychart.graphics.vector.Path Improve this Doc

Path class.
Path is sequence of segments of different type, it can be opened or closed.
To define the internal fill this rule is used EVEN-ODD.
Path always starts with anychart.graphics.vector.Path#moveTo command.
Do not invoke constructor directly. Use anychart.graphics.vector.Stage#path or anychart.graphics.vector.Layer#path to create stage or layer bound path.
To create unbound path use anychart.graphics#path
See also:
anychart.graphics.vector.Stage#path
anychart.graphics.vector.Layer#path
anychart.graphics#path

Methods Overview

Miscellaneous
arcTo()Adds a command to the path that draws an arc of an ellipse.
arcToAsCurves()This method is similar to anychart.graphics.vector.Path#arcTo, but in this case the arc is approximated by Bezier curves.
arcToByEndPoint()Adds a command to the path that draws an arc of an ellipse.
circularArc()Adds a command to the path that draws a circular arc.
clear()Resets all path operations.
close()Adds a command that closes the path by connecting the last point with the first straight line.
curveTo()Adds specified points to the path, drawing sequentially a cubic Bezier curve from the current point to the next.
getCurrentPoint()Returns the last coordinates added to the path.
lineTo()Adds specified points to the current path, drawing sequentially a straight line through the specified coordinates.
moveTo()Moves path cursor position to a specified coordinate.
quadraticCurveTo()Adds specified points to the path, drawing sequentially a quadratic Bezier curve from the current point to the next.

Methods Description

arcTo

Adds a command to the path that draws an arc of an ellipse.
An ellipse with radius rx, ry, starting from an angle fromAngle, with an angular length extent.
The positive direction is considered the direction from a positive direction of the X-axis to a positive direction of the Y-axis, that is clockwise.

Params:

NameTypeDescription
rxnumberThe X-axis radius of the ellipse.
rynumberThe Y-axis radius of the ellipse.
fromAnglenumberThe starting angle, measured in degrees in a clockwise direction.
extentnumberThe angular length of the arc.

Returns:

anychart.graphics.vector.Path - Self instance for method chaining.

arcToAsCurves

This method is similar to anychart.graphics.vector.Path#arcTo, but in this case the arc is approximated by Bezier curves.

Params:

NameTypeDescription
rxnumberThe X-axis radius of the ellipse.
rynumberThe Y-axis radius of the ellipse.
fromAnglenumberThe starting angle, measured in degrees in a clockwise direction.
extentnumberThe angular length of the arc.

Returns:

anychart.graphics.vector.Path - Self instance for method chaining.

arcToByEndPoint

Adds a command to the path that draws an arc of an ellipse.
An arc of an ellipse with radius rx, ry rx, ry from the current point to a point x, y.
The largeArc and clockwiseArc flags define which of the 4 possible arcs is drawn.
Read more at https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes

Params:

NameTypeDescription
xnumberThe X-coordinate of the arc end.
ynumberThe Y-coordinate of the arc end.
rxnumberThe X-axis radius of the ellipse.
rynumberThe Y-axis radius of the ellipse.
largeArcbooleanA flag allowing to draw either the smaller or the larger arc.
clockwiseArcbooleanA flag allowing to draw an arc either in a clockwise or in a counterclockwise direction.

Returns:

anychart.graphics.vector.Path - Self instance for method chaining.

circularArc

Adds a command to the path that draws a circular arc.
An arc with a center in (cx, cy) start angle (from) and end angle (from + sweep), with clockwise and counterclock drawing option.

Params:

NameTypeDefaultDescription
cxnumber
Center x.
cynumber
Center y.
rxnumber
The X-axis radius of the ellipse.
rynumber
The Y-axis radius of the ellipse.
fromAnglenumber
The starting angle, measured in degrees in a clockwise direction.
sweepnumber
Sweep angle in degrees.
lineToboolean
false
Line to start point. If set to true - anychart.graphics.vector.Path#lineTo will be used instead of anychart.graphics.vector.Path#moveTo.

Returns:

anychart.graphics.vector.Path - Self instance for method chaining.

clear

Resets all path operations.

Returns:

anychart.graphics.vector.Path - Self instance for method chaining.

close

Adds a command that closes the path by connecting the last point with the first straight line.

Returns:

anychart.graphics.vector.Path - Self instance for method chaining.

curveTo

Adds specified points to the path, drawing sequentially a cubic Bezier curve from the current point to the next.
Each curve is defined by 3 points (6 coordinates) – two control points and an endpoint.

Params:

NameTypeDescription
control1XnumberThe first control point’s X-coordinate.
control1YnumberThe first control point’s Y-coordinate.
control2XnumberThe second control point’s X-coordinate.
control2YnumberThe second control point’s Y-coordinate.
endXnumberThe endpoint’s X-coordinate.
endYnumberThe endpoint’s Y-coordinate.
var_argsnumberThe coordinates, defining curves, in sets of 6: first control points, then an endpoint (in the same order as the primary parameters).

Returns:

anychart.graphics.vector.Path - Self instance for method chaining.

getCurrentPoint

Returns the last coordinates added to the path.

Returns:

anychart.math.Coordinate - The current coordinates of the cursor.

lineTo

Adds specified points to the current path, drawing sequentially a straight line through the specified coordinates.

Params:

NameTypeDescription
xnumberA target point’s X-coordinate.
ynumberA target point’s Y-coordinate.
var_argsnumberThe target points’ coordinates: each odd parameter is interpreted as X and each even as Y.

Returns:

anychart.graphics.vector.Path - Self instance for method chaining.

moveTo

Moves path cursor position to a specified coordinate.
Remember that if you call the moveTo method a few times in a row, only the last call will be applied.

Params:

NameTypeDescription
xnumberThe target point’s X-coordinate.
ynumberThe target point’s Y-coordinate.

Returns:

anychart.graphics.vector.Path - Self instance for method chaining.

quadraticCurveTo

Adds specified points to the path, drawing sequentially a quadratic Bezier curve from the current point to the next. Each curve is defined by 2 points (4 coordinates) – a control point and an endpoint.

Params:

NameTypeDescription
controlXnumberThe control point’s X-coordinate.
controlYnumberThe control point’s Y-coordinate.
endXnumberThe endpoint’s X-coordinate.
endYnumberThe endpoint’s Y-coordinate.
var_argsnumbercoordinates, defining curves, in sets of four: first the control point, then an endpoint (in the same order as the primary parameters).

Returns:

anychart.graphics.vector.Path - Self instance for method chaining.