graphics.Path Extends Object
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.

Inheritance

Object
     goog.graphics.Path

Constructor

goog.graphics.Path()

Instance Methods

Public Protected Private
appendPath(path)
Appends another path to the end of this path.
Arguments:
path :
The path to append.
Returns:   This path.
code »
arc(cxcyrxryfromAngleextentconnect)
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.
Arguments:
cx :
X coordinate of center of ellipse.
cy :
Y coordinate of center of ellipse.
rx :
Radius of ellipse on x axis.
ry :
Radius of ellipse on y axis.
fromAngle :
Starting angle measured in degrees from the positive x-axis.
extent :
The span of the arc in degrees.
connect :
If true, the starting point of the arc is connected to the current point.
Returns:   The path itself.
code »
arcTo(rxryfromAngleextent)
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.
Arguments:
rx :
Radius of ellipse on x axis.
ry :
Radius of ellipse on y axis.
fromAngle :
Starting angle measured in degrees from the positive x-axis.
extent :
The span of the arc in degrees.
Returns:   The path itself.
code »
arcToAsCurves(rxryfromAngleextent)
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}.
Arguments:
rx :
Radius of ellipse on x axis.
ry :
Radius of ellipse on y axis.
fromAngle :
Starting angle measured in degrees from the positive x-axis.
extent :
The span of the arc in degrees.
Returns:   The path itself.
code »
clear()
Clears the path.
Returns:   The path itself.
code »
clone()
No description.
Returns:   A copy of this path.
code »
close()
Adds a path command to close the path by connecting the last point to the first point.
Returns:   The path itself.
code »
createTransformedPath(tx)
Creates a transformed copy of this path. The path is simplified {@see #createSimplifiedPath} prior to transformation.
Arguments:
tx :
The transformation to perform.
Returns:   A new, transformed path.
code »
curveTo(var_args)
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.
Arguments:
var_args :
The coordinates specifiying each curve in sets of 6 points: {@code [x1, y1]} the first control point, {@code [x2, y2]} the second control point and {@code [x, y]} the end point.
Returns:   The path itself.
code »
forEachSegment(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}.
Arguments:
callback :
function(number, Array)
The function to call with each path segment.
code »
getCurrentPoint()
Returns the coordinates most recently added to the end of the path.
Returns:   An array containing the ending coordinates of the path of the form {@code [x, y]}.
code »
isEmpty()
No description.
Returns:   Whether the path is empty.
code »
isSimple()
Returns true if this path contains no arcs. Simplified paths can be created using {@code createSimplifiedPath}.
Returns:   True if the path contains no arcs.
code »
lineTo(var_args)
Adds points to the path by drawing a straight line to each point.
Arguments:
var_args :
The coordinates of each destination point as x, y value pairs.
Returns:   The path itself.
code »
moveTo(xy)
Adds a point to the path by moving to the specified point. Repaeated moveTo commands are collapsed into a single moveTo.
Arguments:
x :
X coordinate of destination point.
y :
Y coordinate of destination point.
Returns:   The path itself.
code »
transform(tx)
Transforms the path. Only simple paths are transformable. Attempting to transform a non-simple path will throw an error.
Arguments:
tx :
The transformation to perform.
Returns:   The path itself.
code »

Instance Properties

closePoint_ :
The coordinates of the point which closes the path (the point of the last moveTo command).
Code »
currentPoint_ :
The coordinates most recently added to the end of the path.
Code »
simple_ :
Flag for whether this is a simple path (contains no arc segments).
Code »

Static Methods

goog.graphics.Path.createSimplifiedPath(src)
Creates a copy of the given path, replacing {@code arcTo} with {@code arcToAsCurves}. The resulting path is simplified and can be transformed.
Arguments:
src :
The path to simplify.
Returns:   A new simplified path.
code »
goog.graphics.Path.getSegmentCount(segment)
Returns the number of points for a segment type.
Arguments:
segment :
The segment type.
Returns:   The number of points.
code »

Static Properties

goog.graphics.Path.segmentArgCounts_ :
The number of points for each segment type.
Code »
goog.graphics.Path.simplifySegmentMap_ :
A map from segment type to the path function to call to simplify a path.
Code »

Package graphics

Package Reference