# ShapeContour

data class ShapeContour constructor(    val segments: List<Segment>,     val closed: Boolean,     val polarity: YPolarity = YPolarity.CW_NEGATIVE_Y) : ShapeContourProvider

A List for managing a collection of Segments.

## Constructors

fun ShapeContour(    segments: List<Segment>,     closed: Boolean,     polarity: YPolarity = YPolarity.CW_NEGATIVE_Y)

object Companion

## Functions

fun adaptivePositions(distanceTolerance: Double = 0.5): List<Vector2>

Recursively subdivides linear Segments to approximate Bézier curves.

fun adaptivePositionsAndCorners(distanceTolerance: Double = 0.5): Pair<List<Vector2>, List<Boolean>>

Recursively subdivides linear Segments to approximate Bézier curves.

fun adaptivePositionsWithT(distanceTolerance: Double = 0.5): List<Pair<Vector2, Double>>
fun close(): ShapeContour

Closes the path of the ShapeContour.

fun equidistantPositions(pointCount: Int, distanceTolerance: Double = 0.5): List<Vector2>

Returns specified amount of points of equal distance from each other.

fun equidistantPositionsWithT(pointCount: Int, distanceTolerance: Double = 0.5): List<Pair<Vector2, Double>>
fun nearest(point: Vector2): ContourPoint

Projects a point on the ShapeContour

fun normal(ut: Double): Vector2

Calculates the normal for the given ut.

fun on(point: Vector2, error: Double = 5.0): Double?

Checks if given point lies on the path of the ShapeContour.

operator fun plus(other: ShapeContour): ShapeContour
fun pointAtLength(length: Double, distanceTolerance: Double = 0.5): Vector2

Calculates the point at a given distance along this ShapeContour.

fun pose(t: Double): 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.

fun position(ut: Double): Vector2

Returns a point on the path of the ShapeContour.

fun resetCache()
fun sampleEquidistant(pointCount: Int): ShapeContour

Samples the ShapeContour into equidistant linear Segments.

fun sampleLinear(distanceTolerance: Double = 0.5): ShapeContour

Adaptively samples the contour into a new ShapeContour of linearSegments while still approximating the original contour.

fun segment(ut: Double): Pair<Int, Double>

Returns segment number and segment offset in a ShapeContour for the given ut.

fun sub(t0: Double, t1: Double): ShapeContour

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

fun tForLength(length: Double): Double

Estimates the t value for a given length.

fun transform(transform: Matrix44): ShapeContour

Applies linear transformation to ShapeContour.

## Properties

val bounds: Rectangle

Calculates the bounding box of the contour as Rectangle.

val clockwise: ShapeContour

Returns the ShapeContour, but with a clockwise winding.

val closed: Boolean
open override val contour: ShapeContour

the provided contour

val counterClockwise: ShapeContour

Returns the ShapeContour, but with a counterclockwise winding.

val empty: Boolean

Returns true if ShapeContour doesn't contain any Segments.

val exploded: List<ShapeContour>

Converts to a List of single Segments.

val length: Double

Calculates approximate Euclidean length of the contour.

val open: ShapeContour

Opens the path of the ShapeContour.

val polarity: YPolarity
val reversed: ShapeContour

Reverses the direction of Segments and their order.

val segments: List<Segment>
val shape: Shape

Returns Shape representation.

val winding: Winding

Determines the winding order of the ShapeContour.

## Extensions

operator fun ShapeContour.contains(point: Vector2): Boolean

Returns true if given point lies inside the ShapeContour.

fun ShapeContour.difference(other: Shape): Shape

Applies a boolean difference operation between the ShapeContour and another Shape.

fun ShapeContour.intersection(other: Shape): Shape

Applies a boolean intersection operation between the ShapeContour and a Shape.

fun ShapeContour.intersections(other: Segment): List<ContourIntersection>

Calculates a List of all intersections between the ShapeContour and a Segment.

fun ShapeContour.intersections(other: ShapeContour): List<ContourIntersection>

Calculates a List of all intersections between the ShapeContour and another ShapeContour.

fun ShapeContour.intersections(other: Shape): List<ContourIntersection>

Calculates a List of all intersections between the ShapeContour and a Shape.

fun ShapeContour.offset(distance: Double, joinType: SegmentJoin = SegmentJoin.ROUND): ShapeContour

Offsets a ShapeContour's Segments by given distance.

fun ShapeContour.removeLoops(attempts: Int = 0, reverseOrder: Boolean = false): ShapeContour
fun ShapeContour.split(cutter: ShapeContour): List<ShapeContour>

Splits a ShapeContour with another ShapeContour.

fun ShapeContour.split(cutters: List<ShapeContour>): List<ShapeContour>

Splits a ShapeContour with a List of ShapeContours.