Home

# Class goog.graphics.Path

Creates a path object. A path is a sequence of segments and may be open or closed. Path uses the EVEN-ODD fill rule for determining the interior of the path. A path must start with a moveTo command. A "simple" path does not contain any arcs and may be transformed using the {@code transform} method.

Instance Method Summary
| `appendPath(!goog.graphics.Path path) ⇒ !goog.graphics.Path` Appends another path to the end of this path.

`arc(number cx, number cy, number rx, number ry, number fromAngle, number extent, boolean connect) ⇒ !goog.graphics.Path`

Adds a path command to draw an arc centered at the point {@code (cx, cy)} with radius {@code rx} along the x-axis and {@code ry} along the y-axis from {@code startAngle} through {@code extent} degrees. Positive rotation is in the direction from positive x-axis to positive y-axis.

`arcTo(number rx, number ry, number fromAngle, number extent) ⇒ !goog.graphics.Path`

Adds a path command to draw an arc starting at the path's current point, with radius {@code rx} along the x-axis and {@code ry} along the y-axis from {@code startAngle} through {@code extent} degrees. Positive rotation is in the direction from positive x-axis to positive y-axis. This method makes the path non-simple.

| `arcToAsCurves(number rx, number ry, number fromAngle, number extent) ⇒ !goog.graphics.Path` Same as {@code arcTo}, but approximates the arc using bezier curves. .* As a result, this method does not affect the simplified status of this path. The algorithm is adapted from {@code java.awt.geom.ArcIterator}.
| `clear() ⇒ !goog.graphics.Path` Clears the path.
| `clone() ⇒ !goog.graphics.Path`
| `close() ⇒ !goog.graphics.Path` Adds a path command to close the path by connecting the last point to the first point.
| `createTransformedPath(!goog.graphics.AffineTransform tx) ⇒ !goog.graphics.Path` Creates a transformed copy of this path. The path is simplified {@see #createSimplifiedPath} prior to transformation.
| `curveTo((number|undefined) var_args) ⇒ !goog.graphics.Path` Adds points to the path by drawing cubic Bezier curves. Each curve is specified using 3 points (6 coordinates) - two control points and the end point of the curve.

`forEachSegment(function (number, (Array|null)): ? callback)`

Iterates over the path calling the supplied callback once for each path segment. The arguments to the callback function are the segment type and an array of its arguments. The {@code LINETO} and {@code CURVETO} arrays can contain multiple segments of the same type. The number of segments is the length of the array divided by the segment length (2 for lines, 6 for curves). As a convenience the {@code ARCTO} segment also includes the end point as the last two arguments: {@code rx, ry, fromAngle, extent, x, y}.

| `getCurrentPoint() ⇒ ?Array.<number>` Returns the coordinates most recently added to the end of the path.
| `isEmpty() ⇒ boolean`
| `isSimple() ⇒ boolean` Returns true if this path contains no arcs. Simplified paths can be created using {@code createSimplifiedPath}.
| `lineTo((number|undefined) var_args) ⇒ !goog.graphics.Path` Adds points to the path by drawing a straight line to each point.
| `moveTo(number x, number y) ⇒ !goog.graphics.Path` Adds a point to the path by moving to the specified point. Repaeated moveTo commands are collapsed into a single moveTo.
| `transform(!goog.graphics.AffineTransform tx) ⇒ !goog.graphics.Path` Transforms the path. Only simple paths are transformable. Attempting to transform a non-simple path will throw an error.

Static Method Summary
| `createSimplifiedPath(!goog.graphics.Path src) ⇒ !goog.graphics.Path` Creates a copy of the given path, replacing {@code arcTo} with {@code arcToAsCurves}. The resulting path is simplified and can be transformed.
| `getSegmentCount(number segment) ⇒ number` Returns the number of points for a segment type.