Segment

@Serializable
class Segment(val start: Vector2, val control: Array<Vector2>, val end: Vector2, val corner: Boolean = false) : ShapeContourProvider(source)

Creates a new Segment, which specifies a linear or a Bézier curve path between two anchor points (and up to two control points for curvature).

Constructors

Link copied to clipboard
constructor(start: Vector2, control: Array<Vector2>, end: Vector2, corner: Boolean = false)

Functions

Link copied to clipboard
fun adaptivePositions(distanceTolerance: Double = 0.5): List<Vector2>

Recursively subdivides Segment to approximate Bézier curve.

Link copied to clipboard
fun adaptivePositionsWithT(distanceTolerance: Double = 0.5): List<Pair<Vector2, Double>>
Link copied to clipboard
fun copy(start: Vector2 = this.start, control: Array<Vector2> = this.control, end: Vector2 = this.end): Segment

Returns a shallow copy of the Segment.

Link copied to clipboard
Link copied to clipboard

Returns the direction Vector2 of between the Segment anchor points.

Link copied to clipboard
operator fun div(scale: Double): Segment
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
fun equidistantPositions(pointCount: Int, distanceTolerance: Double = 0.5): List<Vector2>

Samples specified amount of points on the Segment.

Link copied to clipboard
fun equidistantPositionsWithT(pointCount: Int, distanceTolerance: Double = 0.5): List<Pair<Vector2, Double>>
Link copied to clipboard

Returns the t values of the extrema for the current Segment.

Link copied to clipboard

Returns the extrema points as Vector2s for current Segment

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Calculates a List of all points where two Segments intersect.

Calculates a List of all points of where a Segment and a Shape intersect.

Calculates a List of all points of where a Segment and a ShapeContour intersect.

Link copied to clipboard
fun isStraight(epsilon: Double = 0.01): Boolean

Determines if the Segment forms a straight line.

Link copied to clipboard
fun lut(size: Int = 100): List<Vector2>
Link copied to clipboard
operator fun minus(right: Segment): Segment
Link copied to clipboard

Find point on segment nearest to given point.

Link copied to clipboard
fun normal(ut: Double, polarity: YPolarity = YPolarity.CW_NEGATIVE_Y): Vector2

Returns a normal Vector2 at given value of t in the range of 0.0 to 1.0.

Link copied to clipboard
fun offset(distance: Double, stepSize: Double = 0.01, yPolarity: YPolarity = YPolarity.CW_NEGATIVE_Y): List<Segment>
Link copied to clipboard
fun on(point: Vector2, error: Double = 5.0): Double?
Link copied to clipboard
operator fun plus(right: Segment): Segment
Link copied to clipboard
fun pointAtLength(length: Double, distanceTolerance: Double = 0.5): Vector2

Calculates the point at a given distance along this Segment.

Link copied to clipboard
fun pose(t: Double, polarity: YPolarity = YPolarity.CW_NEGATIVE_Y): Matrix44

Calculates the pose Matrix44 (i.e. translation and rotation) that describes an orthonormal basis formed by normal and tangent of the contour at t.

Link copied to clipboard

Returns a point on the segment.

Link copied to clipboard
fun reduced(stepSize: Double = 0.01): List<Segment>
Link copied to clipboard
fun scale(scale: Double, polarity: YPolarity): Segment
fun scale(polarity: YPolarity, scale: (Double) -> Double): Segment
Link copied to clipboard

Splits the path into one or two parts, depending on if the cut was successful.

Link copied to clipboard
fun sub(t0: Double, t1: Double): Segment

Samples a new Segment from the current Segment starting at t0 and ending at t1.

Link copied to clipboard
fun tForLength(length: Double): Double

Estimate t value for a given length

Link copied to clipboard
operator fun times(scale: Double): Segment
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun transform(transform: Matrix44): Segment

Applies given linear transformation.

Properties

Link copied to clipboard

Returns the bounding box.

Link copied to clipboard
Link copied to clipboard
open override val contour: ShapeContour

the provided contour

Link copied to clipboard
Link copied to clipboard
val corner: Boolean = false
Link copied to clipboard

Converts the Segment to a cubic Bézier curve.

Link copied to clipboard
Link copied to clipboard

Calculates approximate Euclidean length of the Segment.

Link copied to clipboard

Indicates whether the Segment is linear.

Link copied to clipboard

Converts the Segment to a quadratic Bézier curve.

Link copied to clipboard

Reverses the order of control points of the given path Segment.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Returns the type of the segment.