Top
You are looking at an outdated 7.0.0 version of this document. Switch to the 7.14.3 version to see the up to date information.

class anychart.graphics.vector.Path Improve this Doc

Extends: anychart.graphics.vector.PathBase

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

Methods Overview

Miscellaneous
arcTo()Adds a command to the path that draws an arc of an ellipse with radii rx, ry, starting from an angle
arcToAsCurves()This method is similar to anychart.graphics.vector.Path#arcTo, but in this case the arc is approximated by Bézier curves.
arcToByEndPoint()Adds a command to the path that draws an arc of an ellipse with radii rx, ry rx, ry from the current point to a point x, y.
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 Bézier 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 Bézier curve from the current point to the next.

Methods Description

arcTo

Adds a command to the path that draws an arc of an ellipse with radii 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:

Name Type Description
rx number The X-axis radius of the ellipse.
ry number The Y-axis radius of the ellipse.
fromAngle number The starting angle, measured in degrees in a clockwise direction.
extent number The angular length of the arc.

Returns:

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

Try it:

arcToAsCurves

This method is similar to anychart.graphics.vector.Path#arcTo, but in this case the arc is approximated by Bézier curves. Attention! The method is recommended when transformations are used: using the ordinary anychart.graphics.vector.Path#arcTo and anychart.graphics.vector.Path#arcToByEndPoint methods with transformations leads to productivity loss.
java.awt.geom.ArcIterator algorithm adoptation

Params:

Name Type Description
rx number The X-axis radius of the ellipse.
ry number The Y-axis radius of the ellipse.
fromAngle number The starting angle, measured in degrees in a clockwise direction.
extent number The angular length of the arc.

Returns:

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

arcToByEndPoint

Adds a command to the path that draws an arc of an ellipse with radii 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.
https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes

Params:

Name Type Description
x number The X-coordinate of the arc end.
y number The Y-coordinate of the arc end.
rx number The X-axis radius of the ellipse.
ry number The Y-axis radius of the ellipse.
largeArc boolean A flag allowing to draw either the smaller or the larger arc.
clockwiseArc boolean A flag allowing to draw an arc either in a clockwise or in a counterclockwise direction.

Returns:

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

Try it:

clear

Resets all path operations.

Returns:

anychart.graphics.vector.Path - anychart.graphics.vector.Path 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 - anychart.graphics.vector.Path instance for method chaining.

Try it:

curveTo

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

Params:

Name Type Description
control1X number The first control point’s X-coordinate.
control1Y number The first control point’s Y-coordinate.
control2X number The second control point’s X-coordinate.
control2Y number The second control point’s Y-coordinate.
endX number The endpoint’s X-coordinate.
endY number The endpoint’s Y-coordinate.
var_args number The 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 - anychart.graphics.vector.Path instance for method chaining.

getCurrentPoint

Returns the last coordinates added to the path.

Returns:

anychart.graphics.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:

Name Type Description
x number A target point’s X-coordinate.
y number A target point’s Y-coordinate.
var_args number The target points’ coordinates: each odd parameter is interpreted as X and each even as Y.

Returns:

anychart.graphics.vector.Path - anychart.graphics.vector.Path 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:

Name Type Description
x number The target point’s X-coordinate.
y number The target point’s Y-coordinate.

Returns:

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

quadraticCurveTo

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

Params:

Name Type Description
controlX number The control point’s X-coordinate.
controlY number The control point’s Y-coordinate.
endX number The endpoint’s X-coordinate.
endY number The endpoint’s Y-coordinate.
var_args number coordinates, 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 - anychart.graphics.vector.Path instance for method chaining.