goog.graphics.Path
Classgoog.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.
goog.graphics.Path.Segment
EnumPath segment types. … more
.appendPath(path)
Appends another path to the end of this path.
path
{!goog.graphics.Path
}
goog.graphics.Path
}
.arc(cx, cy, rx, ry, fromAngle, extent, connect)
[deprecated]Deprecated. Use {@code arcTo} or {@code arcToAsCurves} instead.
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.
cx
{number
}
cy
{number
}
rx
{number
}
ry
{number
}
fromAngle
{number
}
extent
{number
}
connect
{boolean
}
goog.graphics.Path
}
.arcTo(rx, ry, fromAngle, extent)
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.
rx
{number
}
ry
{number
}
fromAngle
{number
}
extent
{number
}
goog.graphics.Path
}
.arcToAsCurves(rx, ry, fromAngle, extent)
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}.
rx
{number
}
ry
{number
}
fromAngle
{number
}
extent
{number
}
goog.graphics.Path
}
.clear()
Clears the path.
goog.graphics.Path
}
.clone()
goog.graphics.Path
}
.close()
Adds a path command to close the path by connecting the last point to the first point.
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.
src
{!goog.graphics.Path
}
goog.graphics.Path
}
.createTransformedPath(tx)
Creates a transformed copy of this path. The path is simplified {@see #createSimplifiedPath} prior to transformation.
tx
{!goog.graphics.AffineTransform
}
goog.graphics.Path
}
.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.
var_args
{...number
}
goog.graphics.Path
}
.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}.
callback
{function
(number
, Array
)}
.getCurrentPoint()
Returns the coordinates most recently added to the end of the path.
Array
.<number
>?}
.getSegmentCount(segment)
Returns the number of points for a segment type.
segment
{number
}
number
}
.isEmpty()
boolean
}
.isSimple()
Returns true if this path contains no arcs. Simplified paths can be created using {@code createSimplifiedPath}.
boolean
}
.lineTo(var_args)
Adds points to the path by drawing a straight line to each point.
var_args
{...number
}
goog.graphics.Path
}
.moveTo(x, y)
Adds a point to the path by moving to the specified point. Repeated moveTo commands are collapsed into a single moveTo.
x
{number
}
y
{number
}
goog.graphics.Path
}
.transform(tx)
Transforms the path. Only simple paths are transformable. Attempting to transform a non-simple path will throw an error.
tx
{!goog.graphics.AffineTransform
}
goog.graphics.Path
}