Path

Path contain geometry. Path may be empty, or contain one or more verbs that outline a figure. Path always starts with a move verb to a Cartesian coordinate, and may be followed by additional verbs that add lines or curves.

Adding a close verb makes the geometry into a continuous loop, a closed contour. Path may contain any number of contours, each beginning with a move verb.

Path contours may contain only a move verb, or may also contain lines, quadratic beziers, conics, and cubic beziers. Path contours may be open or closed.

When used to draw a filled area, Path describes whether the fill is inside or outside the geometry. Path also describes the winding rule used to fill overlapping contours.

Internally, Path lazily computes metrics likes bounds and convexity. Call updateBoundsCache to make Path thread safe.

Constructors

Link copied to clipboard
constructor()

Constructs an empty Path. By default, Path has no verbs, no Point, and no weights. FillMode is set to PathFillMode.WINDING.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Returns the approximate byte size of the Path in memory.

Link copied to clipboard

Returns array of two points if Path contains only one line; Verb array has two entries: PathVerb.MOVE, PathVerb.LINE. Returns null if Path is not one line.

Link copied to clipboard

Returns minimum and maximum axes values of Point array.

Link copied to clipboard

Returns the path's fill type. This defines how "inside" is computed. The default value is PathFillMode.WINDING.

Link copied to clipboard

Returns a non-zero, globally unique value. A different value is returned if verb array, Point array, or conic weight changes.

Link copied to clipboard
expect open val isClosed: Boolean

Check if underlying resource is closed.

Link copied to clipboard

Returns true if the path is convex. If necessary, it will first compute the convexity.

Link copied to clipboard

Returns if Path is empty.

Link copied to clipboard

Returns true for finite Point array values between negative Float.MIN_VALUE and positive Float.MAX_VALUE. Returns false for any Point array value of Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, or Float.NaN.

Link copied to clipboard

Returns if contour is closed.

Link copied to clipboard
val isOval: Rect?

Returns oval bounds if this path is recognized as an oval or circle.

Link copied to clipboard
val isRect: Rect?

Returns rect bounds if this path is recognized as a rectangle.

Link copied to clipboard

Returns RRect if this path is recognized as an oval, circle or RRect.

Link copied to clipboard

Returns if Path data is consistent. Corrupt Path data is detected if internal values are out of range or internal storage does not match array dimensions.

Link copied to clipboard

Specifies whether Path is volatile; whether it will be altered or discarded by the caller after it is drawn. Path by default have volatile set false, allowing SkBaseDevice to attach a cache of data which speeds repeated drawing.

Link copied to clipboard

Returns last point on Path in lastPt. Returns null if Point array is empty.

Link copied to clipboard
Link copied to clipboard

Returns all points in Path.

Link copied to clipboard

Returns the number of points in Path. Point count is initially zero.

Link copied to clipboard

Returns a mask, where each set bit corresponds to a SegmentMask constant if Path contains one or more verbs of that type.

Link copied to clipboard

Returns all verbs in Path.

Link copied to clipboard

Returns the number of verbs: PathVerb.MOVE, PathVerb.LINE, PathVerb.QUAD, PathVerb.CONIC, PathVerb.CUBIC, and PathVerb.CLOSE; added to Path.

Functions

Link copied to clipboard
expect open fun close()

Free underlying native resource, peer is useless afterwards.

Link copied to clipboard

Returns minimum and maximum axes values of the lines and curves in Path. Returns (0, 0, 0, 0) if Path contains no points. Returned bounds width and height may be larger or smaller than area affected when Path is drawn.

Link copied to clipboard

Returns true if rect is contained by Path. May return false when rect is contained by Path.

Link copied to clipboard
operator fun contains(p: Point): Boolean

Returns true if the point is contained by Path, taking into account PathFillMode.

Returns true if the point (x, y) is contained by Path, taking into account PathFillMode.

Link copied to clipboard
fun dump(): Path

Writes text representation of Path to standard output. The representation may be directly compiled as C++ code. Floating point values are written with limited precision; it may not be possible to reconstruct original Path from output.

Link copied to clipboard
fun dumpHex(): Path

Writes text representation of Path to standard output. The representation may be directly compiled as C++ code. Floating point values are written in hexadecimal to preserve their exact bit pattern. The output reconstructs the original Path.

Link copied to clipboard
fun getPoint(index: Int): Point

Returns Point at index in Point array. Valid range for index is 0 to countPoints() - 1.

Link copied to clipboard
fun getPoints(points: Array<Point?>?, max: Int): Int

Returns number of points in Path. Up to max points are copied.

Link copied to clipboard
fun getVerbs(verbs: Array<PathVerb?>?, max: Int): Int

Returns the number of verbs in the path. Up to max verbs are copied.

Link copied to clipboard
fun isInterpolatable(compare: Path?): Boolean

Returns true if Path contain equal verbs and equal weights. If Path contain one or more conics, the weights must match.

Link copied to clipboard
open operator override fun iterator(): PathSegmentIterator
Link copied to clipboard
fun makeLerp(ending: Path?, weight: Float): Path

Interpolates between Path with Point array of equal size. Copy verb array and weights to out, and set out Point array to a weighted average of this Point array and ending Point array, using the formula:

Link copied to clipboard

Writes Path to byte buffer.

Link copied to clipboard
fun setVolatile(isVolatile: Boolean): Path

Specifies whether Path is volatile; whether it will be altered or discarded by the caller after it is drawn. Path by default have volatile set false, allowing SkBaseDevice to attach a cache of data which speeds repeated drawing.

Link copied to clipboard
fun swap(other: Path?): Path

Exchanges the verb array, Point array, weights, and FillMode with other. Cached state is also exchanged. swap() internally exchanges pointers, so it is lightweight and does not allocate memory.

Link copied to clipboard
expect open override fun toString(): String
Link copied to clipboard

Updates internal bounds so that subsequent calls to bounds are instantaneous. Unaltered copies of Path may also access cached bounds through bounds.