Path
open class Path
| kotlin.Any | |
| ↳ | android.graphics.Path |
The Path class encapsulates compound (multiple contour) geometric paths consisting of straight line segments, quadratic curves, and cubic curves. It can be drawn with canvas.drawPath(path, paint), either filled or stroked (based on the paint's Style), or it can be used for clipping or to draw text on a path.
Summary
| Nested classes | |
|---|---|
|
Specifies how closed shapes (e.g. rects, ovals) are oriented when they are added to a path. |
|
|
Enum for the ways a path may be filled. |
|
|
The logical operations that can be performed when combining two paths. |
|
| Public constructors | |
|---|---|
Path()Create an empty path |
|
|
Create a new path, copying the contents from the src path. |
|
| Public methods | |
|---|---|
| open Unit |
Add the specified arc to the path as a new contour. |
| open Unit |
Add the specified arc to the path as a new contour. |
| open Unit |
addCircle(x: Float, y: Float, radius: Float, dir: Path.Direction)Add a closed circle contour to the path |
| open Unit |
addOval(oval: RectF, dir: Path.Direction)Add a closed oval contour to the path |
| open Unit |
Add a closed oval contour to the path |
| open Unit |
Add a copy of src to the path |
| open Unit |
Add a copy of src to the path, transformed by matrix |
| open Unit |
Add a copy of src to the path, offset by (dx,dy) |
| open Unit |
addRect(rect: RectF, dir: Path.Direction)Add a closed rectangle contour to the path |
| open Unit |
Add a closed rectangle contour to the path |
| open Unit |
addRoundRect(rect: RectF, rx: Float, ry: Float, dir: Path.Direction)Add a closed round-rectangle contour to the path |
| open Unit |
addRoundRect(rect: RectF, radii: FloatArray, dir: Path.Direction)Add a closed round-rectangle contour to the path. |
| open Unit |
addRoundRect(left: Float, top: Float, right: Float, bottom: Float, rx: Float, ry: Float, dir: Path.Direction)Add a closed round-rectangle contour to the path |
| open Unit |
addRoundRect(left: Float, top: Float, right: Float, bottom: Float, radii: FloatArray, dir: Path.Direction)Add a closed round-rectangle contour to the path. |
| open FloatArray |
approximate(acceptableError: Float)Approximate the |
| open Unit |
Append the specified arc to the path as a new contour. |
| open Unit |
Append the specified arc to the path as a new contour. |
| open Unit |
arcTo(left: Float, top: Float, right: Float, bottom: Float, startAngle: Float, sweepAngle: Float, forceMoveTo: Boolean)Append the specified arc to the path as a new contour. |
| open Unit |
close()Close the current contour. |
| open Unit |
computeBounds(bounds: RectF)Compute the bounds of the control points of the path, and write the answer into bounds. |
| open Unit |
computeBounds(bounds: RectF, exact: Boolean)Compute the bounds of the control points of the path, and write the answer into bounds. |
| open Unit |
Add a quadratic bezier from the last point, approaching control point (x1,y1), and ending at (x2,y2), weighted by |
| open Unit |
Add a cubic bezier from the last point, approaching control points (x1,y1) and (x2,y2), and ending at (x3,y3). |
| open Path.FillType |
Return the path's fill type. |
| open Int |
Returns the generation ID of this path. |
| open PathIterator |
Returns an iterator over the segments of this path. |
| open Unit |
incReserve(extraPtCount: Int)Hint to the path to prepare for adding more points. |
| open Boolean |
interpolate(otherPath: Path, t: Float, interpolatedPath: Path)This method will linearly interpolate from this path to |
| open Boolean |
isConvex()Returns the path's convexity, as defined by the content of the path. |
| open Boolean |
isEmpty()Returns true if the path is empty (contains no lines or curves) |
| open Boolean |
isInterpolatable(otherPath: Path)Two paths can be interpolated, by calling |
| open Boolean |
Returns true if the filltype is one of the INVERSE variants |
| open Boolean |
Returns true if the path specifies a rectangle. |
| open Unit |
Add a line from the last point to the specified point (x,y). |
| open Unit |
Set the beginning of the next contour to the point (x,y). |
| open Unit |
Offset the path by (dx,dy) |
| open Unit |
Offset the path by (dx,dy) |
| open Boolean |
Set this path to the result of applying the Op to the two specified paths. |
| open Boolean |
Set this path to the result of applying the Op to this path and the specified path. |
| open Unit |
Add a quadratic bezier from the last point, approaching control point (x1,y1), and ending at (x2,y2). |
| open Unit |
Same as conicTo, but the coordinates are considered relative to the last point on this contour. |
| open Unit |
Same as cubicTo, but the coordinates are considered relative to the current point on this contour. |
| open Unit |
Same as lineTo, but the coordinates are considered relative to the last point on this contour. |
| open Unit |
Set the beginning of the next contour relative to the last point on the previous contour. |
| open Unit |
Same as quadTo, but the coordinates are considered relative to the last point on this contour. |
| open Unit |
reset()Clear any lines and curves from the path, making it empty. |
| open Unit |
rewind()Rewinds the path: clears any lines and curves from the path but keeps the internal data structure for faster reuse. |
| open Unit |
Replace the contents of this with the contents of src. |
| open Unit |
setFillType(ft: Path.FillType)Set the path's fill type. |
| open Unit |
setLastPoint(dx: Float, dy: Float)Sets the last point of the path. |
| open Unit |
Toggles the INVERSE state of the filltype |
| open Unit |
Transform the points in this path by matrix. |
| open Unit |
Transform the points in this path by matrix, and write the answer into dst. |
Public constructors
Path
Path(src: Path?)
Create a new path, copying the contents from the src path.
| Parameters | |
|---|---|
src |
Path?: The path to copy from when initializing the new path. This value may be null. |
Public methods
addArc
open fun addArc(
oval: RectF,
startAngle: Float,
sweepAngle: Float
): Unit
Add the specified arc to the path as a new contour.
| Parameters | |
|---|---|
oval |
RectF: The bounds of oval defining the shape and size of the arc. This value cannot be null. |
startAngle |
Float: Starting angle (in degrees) where the arc begins |
sweepAngle |
Float: Sweep angle (in degrees) measured clockwise |
addArc
open fun addArc(
left: Float,
top: Float,
right: Float,
bottom: Float,
startAngle: Float,
sweepAngle: Float
): Unit
Add the specified arc to the path as a new contour.
| Parameters | |
|---|---|
startAngle |
Float: Starting angle (in degrees) where the arc begins |
sweepAngle |
Float: Sweep angle (in degrees) measured clockwise |
addCircle
open fun addCircle(
x: Float,
y: Float,
radius: Float,
dir: Path.Direction
): Unit
Add a closed circle contour to the path
| Parameters | |
|---|---|
x |
Float: The x-coordinate of the center of a circle to add to the path |
y |
Float: The y-coordinate of the center of a circle to add to the path |
radius |
Float: The radius of a circle to add to the path |
dir |
Path.Direction: The direction to wind the circle's contour. This value cannot be null. |
addOval
open fun addOval(
oval: RectF,
dir: Path.Direction
): Unit
Add a closed oval contour to the path
| Parameters | |
|---|---|
oval |
RectF: The bounds of the oval to add as a closed contour to the path. This value cannot be null. |
dir |
Path.Direction: The direction to wind the oval's contour. This value cannot be null. |
addOval
open fun addOval(
left: Float,
top: Float,
right: Float,
bottom: Float,
dir: Path.Direction
): Unit
Add a closed oval contour to the path
| Parameters | |
|---|---|
dir |
Path.Direction: The direction to wind the oval's contour. This value cannot be null. |
addPath
open fun addPath(src: Path): Unit
Add a copy of src to the path
| Parameters | |
|---|---|
src |
Path: The path that is appended to the current path. This value cannot be null. |
addPath
open fun addPath(
src: Path,
matrix: Matrix
): Unit
Add a copy of src to the path, transformed by matrix
| Parameters | |
|---|---|
src |
Path: The path to add as a new contour. This value cannot be null. |
matrix |
Matrix: This value cannot be null. |
addPath
open fun addPath(
src: Path,
dx: Float,
dy: Float
): Unit
Add a copy of src to the path, offset by (dx,dy)
| Parameters | |
|---|---|
src |
Path: The path to add as a new contour. This value cannot be null. |
dx |
Float: The amount to translate the path in X as it is added |
addRect
open fun addRect(
rect: RectF,
dir: Path.Direction
): Unit
Add a closed rectangle contour to the path
| Parameters | |
|---|---|
rect |
RectF: The rectangle to add as a closed contour to the path. This value cannot be null. |
dir |
Path.Direction: The direction to wind the rectangle's contour. This value cannot be null. |
addRect
open fun addRect(
left: Float,
top: Float,
right: Float,
bottom: Float,
dir: Path.Direction
): Unit
Add a closed rectangle contour to the path
| Parameters | |
|---|---|
left |
Float: The left side of a rectangle to add to the path |
top |
Float: The top of a rectangle to add to the path |
right |
Float: The right side of a rectangle to add to the path |
bottom |
Float: The bottom of a rectangle to add to the path |
dir |
Path.Direction: The direction to wind the rectangle's contour. This value cannot be null. |
addRoundRect
open fun addRoundRect(
rect: RectF,
rx: Float,
ry: Float,
dir: Path.Direction
): Unit
Add a closed round-rectangle contour to the path
| Parameters | |
|---|---|
rect |
RectF: The bounds of a round-rectangle to add to the path. This value cannot be null. |
rx |
Float: The x-radius of the rounded corners on the round-rectangle |
ry |
Float: The y-radius of the rounded corners on the round-rectangle |
dir |
Path.Direction: The direction to wind the round-rectangle's contour. This value cannot be null. |
addRoundRect
open fun addRoundRect(
rect: RectF,
radii: FloatArray,
dir: Path.Direction
): Unit
Add a closed round-rectangle contour to the path. Each corner receives two radius values [X, Y]. The corners are ordered top-left, top-right, bottom-right, bottom-left
| Parameters | |
|---|---|
rect |
RectF: The bounds of a round-rectangle to add to the path. This value cannot be null. |
radii |
FloatArray: Array of 8 values, 4 pairs of [X,Y] radii. This value cannot be null. |
dir |
Path.Direction: The direction to wind the round-rectangle's contour. This value cannot be null. |