🌈 Create new beautiful Compose Gradients with our new wesite ->
Class

PathSegment

A path segment represents a curve (line, cubic, quadratic or conic) or a command inside a fully formed Path object.

Source set: Common
public class PathSegment(
    public val type: Type,
    @get:Suppress("ArrayReturn") public val points: FloatArray,
    public val weight: Float,
)

A path segment represents a curve (line, cubic, quadratic or conic) or a command inside a fully formed Path object.

A segment is identified by a type which in turns defines how many points are available (from 0 to 4 points, each point is represented by 2 floats) and whether the weight is meaningful. Please refer to the documentation of each type for more information.

A segment with the Move or Close is usually represented by the singletons DoneSegment and CloseSegment respectively.

Functions

equals

Source set: Common
override fun equals(other: Any?): Boolean

hashCode

Source set: Common
override fun hashCode(): Int

toString

Source set: Common
override fun toString(): String

Members

Type

Source set: Common
public enum class Type {
        /**
         * Move command, the path segment contains 1 point indicating the move destination. The
         * weight is set 0.0f and not meaningful.
         */
        Move,
        /**
         * Line curve, the path segment contains 2 points indicating the two extremities of the
         * line. The weight is set 0.0f and not meaningful.
         */
        Line,
        /**
         * Quadratic curve, the path segment contains 3 points in the following order:
         * - Start point
         * - Control point
         * - End point
         *
         * The weight is set 0.0f and not meaningful.
         */
        Quadratic,
        /**
         * Conic curve, the path segment contains 3 points in the following order:
         * - Start point
         * - Control point
         * - End point
         *
         * The curve is weighted by the [weight][PathSegment.weight] property.
         *
         * The conic weight determines the amount of influence conic control point has on the curve.
         * If the weight is less than one, the curve represents an elliptical section. If the weight
         * is greater than one, the curve represents a hyperbolic section. If the weight equals one,
         * the curve represents a parabolic section.
         */
        Conic,
        /**
         * Cubic curve, the path segment contains 4 points in the following order:
         * - Start point
         * - First control point
         * - Second control point
         * - End point
         *
         * The weight is set 0.0f and not meaningful.
         */
        Cubic,
        /**
         * Close command, close the current contour by joining the last point added to the path with
         * the first point of the current contour. The segment does not contain any point. The
         * weight is set 0.0f and not meaningful.
         */
        Close,
        /**
         * Done command, which indicates that no further segment will be found in the path. It
         * typically indicates the end of an iteration over a path and can be ignored.
         */
        Done,
    }

Type of a given segment in a Path, either a command (Type.Move, Type.Close, Type.Done) or a curve (Type.Line, Type.Cubic, Type.Quadratic, Type.Conic).

Members

Move

Source set: Common
Move

Move command, the path segment contains 1 point indicating the move destination. The weight is set 0.0f and not meaningful.

Line

Source set: Common
Line

Line curve, the path segment contains 2 points indicating the two extremities of the line. The weight is set 0.0f and not meaningful.

Quadratic

Source set: Common
Quadratic

Quadratic curve, the path segment contains 3 points in the following order:

  • Start point
  • Control point
  • End point

The weight is set 0.0f and not meaningful.

Conic

Source set: Common
Conic

Conic curve, the path segment contains 3 points in the following order:

  • Start point
  • Control point
  • End point

The curve is weighted by the weight property.

The conic weight determines the amount of influence conic control point has on the curve. If the weight is less than one, the curve represents an elliptical section. If the weight is greater than one, the curve represents a hyperbolic section. If the weight equals one, the curve represents a parabolic section.

Cubic

Source set: Common
Cubic

Cubic curve, the path segment contains 4 points in the following order:

  • Start point
  • First control point
  • Second control point
  • End point

The weight is set 0.0f and not meaningful.

Close

Source set: Common
Close

Close command, close the current contour by joining the last point added to the path with the first point of the current contour. The segment does not contain any point. The weight is set 0.0f and not meaningful.

Done

Source set: Common
Done

Done command, which indicates that no further segment will be found in the path. It typically indicates the end of an iteration over a path and can be ignored.