# ShapeContour

data class ShapeContour(segments: List<Segment>, closed: Boolean, polarity: YPolarity) : ShapeContourProvider

A List for managing a collection of Segments.

## Constructors

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

Companion
common
object Companion

## Functions

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

Recursively subdivides linear Segments to approximate Bézier curves.

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

Recursively subdivides linear Segments to approximate Bézier curves.

common
fun adaptivePositionsAndDirection(distanceTolerance: Double = 0.5): Pair<List<Vector2>, List<Vector2>>

Recursively subdivides linear Segments to approximate Bézier curves.

close
common
fun close(): ShapeContour

Closes the path of the ShapeContour.

equidistantPositions
common
fun equidistantPositions(pointCount: Int): List<Vector2>

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

nearest
common
fun nearest(point: Vector2): ContourPoint

Projects a point on the ShapeContour

normal
common
fun normal(ut: Double): Vector2

Calculates the normal for given value of `t`.

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

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

plus
common
operator fun plus(other: ShapeContour): ShapeContour
pose
common
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.

position
common
fun position(ut: Double): Vector2

Returns a point on the path of the ShapeContour.

sampleEquidistant
common
fun sampleEquidistant(pointCount: Int): ShapeContour

Samples the ShapeContour into equidistant linear Segments.

sampleLinear
common
fun sampleLinear(distanceTolerance: Double = 0.5): ShapeContour

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

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

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

tForLength
common
fun tForLength(length: Double): Double

Estimates the t value for a given length.

transform
common
fun transform(transform: Matrix44): ShapeContour

Applies linear transformation to ShapeContour.

## Properties

bounds
common
val bounds: Rectangle

Calculates the bounding box of the contour as Rectangle.

clockwise
common
val clockwise: ShapeContour

Returns the ShapeContour, but with a clockwise winding.

closed
common
val closed: Boolean
contour
common
open override val contour: ShapeContour

the provided contour

counterClockwise
common
val counterClockwise: ShapeContour

Returns the ShapeContour, but with a counterclockwise winding.

empty
common
val empty: Boolean

Returns true if ShapeContour doesn't contain any Segments.

exploded
common
val exploded: List<ShapeContour>

Converts to a List of single Segments.

length
common
val length: Double

Calculates approximate Euclidean length of the contour.

open
common
val open: ShapeContour

Opens the path of the ShapeContour.

polarity
common
val polarity: YPolarity
reversed
common
val reversed: ShapeContour

Reverses the direction of Segments and their order.

segments
common
val segments: List<Segment>
shape
common
val shape: Shape

Returns Shape representation.

winding
common
val winding: Winding

Determines the winding order of the ShapeContour.

## Extensions

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

Returns true if given point lies inside the ShapeContour.

difference
common
fun ShapeContour.difference(other: Shape): Shape

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

intersection
common
fun ShapeContour.intersection(other: Shape): Shape

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

intersections
common
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.

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

Offsets a ShapeContour's Segments by given distance.

removeLoops
common
fun ShapeContour.removeLoops(attempts: Int = 0, reverseOrder: Boolean = false): ShapeContour
split
common
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.

union