androidx.compose.ui.graphics
Path
Interface · from org.jetbrains.compose.ui:ui-graphics:1.12.2
No hand-written docs yet.
interface Path
How to get one
Create it
Path()
Ready-made values and functions that return it
Used by
Parameters that take a Path.
DrawScope.drawPath(path)Path.addPath(path)Path.and(path)Path.combine(path1, path2)Path.minus(path)Path.op(path1, path2)Path.or(path)Path.plus(path)Path.xor(path)toPath(path)
Properties
fillType
val fillType: PathFillType
Determines how the interior of this path is calculated.
isConvex
val isConvex: Boolean
Returns the path's convexity, as defined by the content of the path.
isEmpty
val isEmpty: Boolean
Returns true if the path is empty (contains no lines or curves)
Functions
moveTo
fun moveTo(x: Float, y: Float)
Starts a new subpath at the given coordinate
relativeMoveTo
fun relativeMoveTo(dx: Float, dy: Float)
Starts a new subpath at the given offset from the current point
lineTo
fun lineTo(x: Float, y: Float)
Adds a straight line segment from the current point to the given point
relativeLineTo
fun relativeLineTo(dx: Float, dy: Float)
Adds a straight line segment from the current point to the point at the given offset from the current point.
quadraticTo
fun quadraticTo(
x1: Float,
y1: Float,
x2: Float,
y2: Float,
)
Adds a quadratic bezier segment that curves from the current point to the given point (x2, y2), using the control point (x1, y1).
relativeQuadraticTo
fun relativeQuadraticTo(
dx1: Float,
dy1: Float,
dx2: Float,
dy2: Float,
)
Adds a quadratic bezier segment that curves from the current point to the point at the offset (dx2, dy2) from the current point, using the control point at the offset (dx1, dy1) from the current point.
cubicTo
fun cubicTo(
x1: Float,
y1: Float,
x2: Float,
y2: Float,
x3: Float,
y3: Float,
)
Adds a cubic bezier segment that curves from the current point to the given point (x3, y3), using the control points (x1, y1) and (x2, y2).
relativeCubicTo
fun relativeCubicTo(
dx1: Float,
dy1: Float,
dx2: Float,
dy2: Float,
dx3: Float,
dy3: Float,
)
Adds a cubic bezier segment that curves from the current point to the point at the offset (dx3, dy3) from the current point, using the control points at the offsets (dx1, dy1) and (dx2, dy2) from the current point.
arcToRad
fun arcToRad(
rect: Rect,
startAngleRadians: Float,
sweepAngleRadians: Float,
forceMoveTo: Boolean,
)
If the forceMoveTo argument is false, adds a straight line segment and an arc segment.
arcTo
fun arcTo(
rect: Rect,
startAngleDegrees: Float,
sweepAngleDegrees: Float,
forceMoveTo: Boolean,
)
If the forceMoveTo argument is false, adds a straight line segment and an arc segment.
addRect
fun addRect(
rect: Rect,
direction: Direction = Direction.CounterClockwise,
)
Adds a new subpath that consists of four lines that outline the given rectangle. The direction to wind the rectangle's contour is specified by direction.
addOval
fun addOval(
oval: Rect,
direction: Direction = Direction.CounterClockwise,
)
Adds a new subpath that consists of a curve that forms the ellipse that fills the given rectangle.
addRoundRect
fun addRoundRect(
roundRect: RoundRect,
direction: Direction = Direction.CounterClockwise,
)
Add a round rectangle shape to the path from the given RoundRect. The direction to wind the rectangle's contour is specified by direction.
addArcRad
fun addArcRad(
oval: Rect,
startAngleRadians: Float,
sweepAngleRadians: Float,
)
Adds a new subpath with one arc segment that consists of the arc that follows the edge of the oval bounded by the given rectangle, from startAngle radians around the oval up to startAngle + sweepAngle radians around the oval, with zero radians being the point on the right hand side of the oval that crosses the horizontal line that intersects the center of the rectangle and with positive angles going clockwise around the oval.
addArc
fun addArc(
oval: Rect,
startAngleDegrees: Float,
sweepAngleDegrees: Float,
)
Adds a new subpath with one arc segment that consists of the arc that follows the edge of the oval bounded by the given rectangle, from startAngle degrees around the oval up to startAngle + sweepAngle degrees around the oval, with zero degrees being the point on the right hand side of the oval that crosses the horizontal line that intersects the center of the rectangle and with positive angles going clockwise around the oval.
addPath
fun addPath(
path: Path,
offset: Offset = Offset.Zero,
)
Adds a new subpath that consists of the given path offset by the given offset.
close
fun close()
Closes the last subpath, as if a straight line had been drawn from the current point to the first point of the subpath.
reset
fun reset()
Clears the Path object of all subpaths, returning it to the same state it had when it was created. The current point is reset to the origin. This does NOT change the fill-type setting.
rewind
fun rewind()
Rewinds the path: clears any lines and curves from the path but keeps the internal data structure for faster reuse.
translate
fun translate(offset: Offset)
Translates all the segments of every subpath by the given offset.
transform
fun transform(matrix: Matrix)
Transform the points in this path by the provided matrix
getBounds
fun getBounds(): Rect
Compute the bounds of the control points of the path, and write the answer into bounds. If the path contains 0 or 1 points, the bounds is set to (0,0,0,0)
iterator
fun iterator(): PathIterator
Creates a new PathIterator for this Path that evaluates conics as quadratics. To preserve conics, use the Path.iterator function that takes a PathIterator.ConicEvaluation parameter.
fun iterator(
conicEvaluation: PathIterator.ConicEvaluation,
tolerance: Float = 0.25f,
): PathIterator
Creates a new PathIterator for this Path. To preserve conics as conics (not convert them to quadratics), set conicEvaluation to PathIterator.ConicEvaluation.AsConic.
op
fun op(
path1: Path,
path2: Path,
operation: PathOperation,
): Boolean
Set this path to the result of applying the Op to the two specified paths. The resulting path will be constructed from non-overlapping contours. The curve order is reduced where possible so that cubics may be turned into quadratics, and quadratics maybe turned into lines.
plus
fun plus(path: Path)
Returns the union of two paths as a new Path.
minus
fun minus(path: Path)
Returns the difference of two paths as a new Path.
or
fun or(path: Path): Path
Returns the union of two paths as a new Path.
and
fun and(path: Path)
Returns the intersection of two paths as a new Path. If the paths do not intersect, returns an empty path.
xor
fun xor(path: Path)
Returns the union minus the intersection of two paths as a new Path.
combine
fun combine(
operation: PathOperation,
path1: Path,
path2: Path,
): Path
Combines the two paths according to the manner specified by the given operation.
Nested types
Direction