ShapeContour

data class ShapeContour @JvmOverloads 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

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

Types

Link copied to clipboard
object Companion

Functions

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

Recursively subdivides linear Segments to approximate Bézier curves.

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

Recursively subdivides linear Segments to approximate Bézier curves.

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

Closes the path of the ShapeContour.

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

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

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

Projects a point on the ShapeContour

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

Calculates the normal for the given ut.

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

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

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

Calculates the point at a given distance along this ShapeContour.

Link copied to clipboard
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.

Link copied to clipboard
fun position(ut: Double): Vector2

Returns a point on the path of the ShapeContour.

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

Samples the ShapeContour into equidistant linear Segments.

Link copied to clipboard
fun sampleLinear(distanceTolerance: Double = 0.5): ShapeContour

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

Link copied to clipboard
fun segment(ut: Double): Pair<Int, Double>

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

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

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

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

Estimates the t value for a given length.

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

Applies linear transformation to ShapeContour.

Properties

Link copied to clipboard
val bounds: Rectangle

Calculates the bounding box of the contour as Rectangle.

Link copied to clipboard
val clockwise: ShapeContour

Returns the ShapeContour, but with a clockwise winding.

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

the provided contour

Link copied to clipboard
val counterClockwise: ShapeContour

Returns the ShapeContour, but with a counterclockwise winding.

Link copied to clipboard
val empty: Boolean

Returns true if ShapeContour doesn't contain any Segments.

Link copied to clipboard
val exploded: List<ShapeContour>

Converts to a List of single Segments.

Link copied to clipboard
val length: Double

Calculates approximate Euclidean length of the contour.

Link copied to clipboard
val open: ShapeContour

Opens the path of the ShapeContour.

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

Reverses the direction of Segments and their order.

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

Returns Shape representation.

Link copied to clipboard
val winding: Winding

Determines the winding order of the ShapeContour.

Extensions

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

Returns true if given point lies inside the ShapeContour.

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

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

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

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

Link copied to clipboard
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.

Link copied to clipboard
fun ShapeContour.offset(distance: Double, joinType: SegmentJoin = SegmentJoin.ROUND): ShapeContour

Offsets a ShapeContour's Segments by given distance.

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

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

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

Sources

Link copied to clipboard