ShapeContour

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

A List for managing a collection of Segments.

Constructors

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

Types

Companion
Link copied to clipboard
common
object Companion

Functions

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

Recursively subdivides linear Segments to approximate Bézier curves.

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

Recursively subdivides linear Segments to approximate Bézier curves.

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

Recursively subdivides linear Segments to approximate Bézier curves.

close
Link copied to clipboard
common
fun close(): ShapeContour

Closes the path of the ShapeContour.

equidistantPositions
Link copied to clipboard
common
fun equidistantPositions(pointCount: Int): List<Vector2>

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

nearest
Link copied to clipboard
common
fun nearest(point: Vector2): ContourPoint

Projects a point on the ShapeContour

normal
Link copied to clipboard
common
fun normal(ut: Double): Vector2

Calculates the normal for given value of t.

on
Link copied to clipboard
common
fun on(point: Vector2, error: Double = 5.0): Double?

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

plus
Link copied to clipboard
common
operator fun plus(other: ShapeContour): ShapeContour
pose
Link copied to clipboard
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
Link copied to clipboard
common
fun position(ut: Double): Vector2

Returns a point on the path of the ShapeContour.

sampleEquidistant
Link copied to clipboard
common
fun sampleEquidistant(pointCount: Int): ShapeContour

Samples the ShapeContour into equidistant linear Segments.

sampleLinear
Link copied to clipboard
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
Link copied to clipboard
common
fun sub(t0: Double, t1: Double): ShapeContour

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

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

Estimates the t value for a given length.

transform
Link copied to clipboard
common
fun transform(transform: Matrix44): ShapeContour

Applies linear transformation to ShapeContour.

Properties

bounds
Link copied to clipboard
common
val bounds: Rectangle

Calculates the bounding box of the contour as Rectangle.

clockwise
Link copied to clipboard
common
val clockwise: ShapeContour

Returns the ShapeContour, but with a clockwise winding.

closed
Link copied to clipboard
common
val closed: Boolean
contour
Link copied to clipboard
common
open override val contour: ShapeContour

the provided contour

counterClockwise
Link copied to clipboard
common
val counterClockwise: ShapeContour

Returns the ShapeContour, but with a counterclockwise winding.

empty
Link copied to clipboard
common
val empty: Boolean

Returns true if ShapeContour doesn't contain any Segments.

exploded
Link copied to clipboard
common
val exploded: List<ShapeContour>

Converts to a List of single Segments.

length
Link copied to clipboard
common
val length: Double

Calculates approximate Euclidean length of the contour.

open
Link copied to clipboard
common
val open: ShapeContour

Opens the path of the ShapeContour.

polarity
Link copied to clipboard
common
val polarity: YPolarity
reversed
Link copied to clipboard
common
val reversed: ShapeContour

Reverses the direction of Segments and their order.

segments
Link copied to clipboard
common
val segments: List<Segment>
shape
Link copied to clipboard
common
val shape: Shape

Returns Shape representation.

winding
Link copied to clipboard
common
val winding: Winding

Determines the winding order of the ShapeContour.

Extensions

contains
Link copied to clipboard
common
operator fun ShapeContour.contains(point: Vector2): Boolean

Returns true if given point lies inside the ShapeContour.

difference
Link copied to clipboard
common
fun ShapeContour.difference(other: Shape): Shape

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

intersection
Link copied to clipboard
common
fun ShapeContour.intersection(other: Shape): Shape

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

intersections
Link copied to clipboard
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
Link copied to clipboard
common
fun ShapeContour.offset(distance: Double, joinType: SegmentJoin = SegmentJoin.ROUND): ShapeContour

Offsets a ShapeContour's Segments by given distance.

removeLoops
Link copied to clipboard
common
fun ShapeContour.removeLoops(attempts: Int = 0, reverseOrder: Boolean = false): ShapeContour
split
Link copied to clipboard
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
Link copied to clipboard
common
fun ShapeContour.union(other: Shape): Shape

Applies a boolean org.openrndr.shape.union operation between the ShapeContour and a Shape.