goog.graphics.Path
Provided By | |
---|---|
All Known Direct Subclasses |
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 transform
method.
new Path()
Parameters | None. |
---|
Instance Methods
this.appendPath( path ) → goog.graphics.Path
goog.graphics.Path
Appends another path to the end of this path.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.arc( cx, cy, rx, ry, fromAngle, extent, connect ) → goog.graphics.Path
goog.graphics.Path
Adds a path command to draw an arc centered at the point (cx, cy)
with radius rx
along the x-axis and ry
along the y-axis from
startAngle
through extent
degrees. Positive rotation is in
the direction from positive x-axis to positive y-axis.
warning Deprecated | Use |
---|
Parameters |
| ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.arcTo( rx, ry, fromAngle, extent ) → goog.graphics.Path
goog.graphics.Path
Adds a path command to draw an arc starting at the path's current point,
with radius rx
along the x-axis and ry
along the y-axis from
startAngle
through extent
degrees. Positive rotation is in
the direction from positive x-axis to positive y-axis.
This method makes the path non-simple.
Parameters |
| ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.arcToAsCurves( rx, ry, fromAngle, extent ) → goog.graphics.Path
goog.graphics.Path
Same as 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 java.awt.geom.ArcIterator
.
Parameters |
| ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.clear() → goog.graphics.Path
goog.graphics.Path
this.clone() → goog.graphics.Path
goog.graphics.Path
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.close() → goog.graphics.Path
goog.graphics.Path
Adds a path command to close the path by connecting the last point to the first point.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.createTransformedPath( tx ) → goog.graphics.Path
goog.graphics.Path
Creates a transformed copy of this path. The path is simplified #createSimplifiedPath prior to transformation.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.curveTo( ...var_args ) → goog.graphics.Path
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.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.forEachSegment( callback ) → void
void
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 LINETO
and 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 ARCTO
segment also includes the end point as the
last two arguments: rx, ry, fromAngle, extent, x, y
.
Parameters |
|
---|
this.isEmpty() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isSimple() → boolean
boolean
Returns true if this path contains no arcs. Simplified paths can be
created using createSimplifiedPath
.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.lineTo( ...var_args ) → goog.graphics.Path
goog.graphics.Path
Adds points to the path by drawing a straight line to each point.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.moveTo( x, y ) → goog.graphics.Path
goog.graphics.Path
Adds a point to the path by moving to the specified point. Repeated moveTo commands are collapsed into a single moveTo.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.transform( tx ) → goog.graphics.Path
goog.graphics.Path
Transforms the path. Only simple paths are transformable. Attempting to transform a non-simple path will throw an error.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
Static Functions
Path.createSimplifiedPath( src ) → goog.graphics.Path
goog.graphics.Path
Creates a copy of the given path, replacing arcTo
with
arcToAsCurves
. The resulting path is simplified and can
be transformed.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
Path.getSegmentCount( segment ) → number
number