Shape

class Shape(val contours: List<ShapeContour>) : ShapeProvider

A simple interface for managing a List of ShapeContour.

Constructors

Link copied to clipboard
fun Shape(contours: List<ShapeContour>)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun hole(index: Int): ShapeContour

The indexed hole of the shape.

Link copied to clipboard
fun map(mapper: (ShapeContour) -> ShapeContour): Shape

Applies a map to the shape. Maps every contour.

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

Projects a point on the contours of a Shape

Link copied to clipboard
fun polygon(distanceTolerance: Double = 0.5): Shape
Link copied to clipboard
fun randomPoints(pointCount: Int, random: Random = Random.Default): List<Vector2>

Generates specified amount of random points that lie inside the Shape.

Link copied to clipboard
fun resetCache()
Link copied to clipboard
fun splitCompounds(winding: Winding = Winding.CLOCKWISE): List<Shape>

Splits a org.openrndr.shape.compound shape into separate shapes.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun transform(transform: Matrix44): Shape

Applies a linear transformation to the Shape.

Properties

Link copied to clipboard
val area: Double

Calculates approximate area for this shape (through triangulation).

Link copied to clipboard
val bounds: Rectangle
Link copied to clipboard
val closedContours: List<ShapeContour>

Lists all ShapeContours with a closed topology.

Link copied to clipboard
val compound: Boolean

Checks whether the Shape is org.openrndr.shape.compound or not.

Link copied to clipboard
val contours: List<ShapeContour>
Link copied to clipboard
val empty: Boolean

Returns true if Shape contains no ShapeContours.

Link copied to clipboard
val linear: Boolean

Returns true if Shape consists solely of ShapeContours, where each Segment is a line segment.

Link copied to clipboard
val openContours: List<ShapeContour>

Lists all ShapeContours with an open topology.

Link copied to clipboard
val outline: ShapeContour

The outline of the shape.

Link copied to clipboard
open override val shape: Shape

the provided shape

Link copied to clipboard
val topology: ShapeTopology

Indicates the Shape topology.

Link copied to clipboard
val triangulation: List<Triangle>

Triangulates Shape into a List of Triangles.

Extensions

Link copied to clipboard
operator fun Shape.contains(v: Vector2): Boolean

Returns true if given Vector2 is inside the Shape.

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

Applies a boolean difference operation between two Shapes.

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

Applies a boolean intersection operation between two Shapes.

Link copied to clipboard
fun Shape.intersections(other: Shape): List<ContourIntersection>

Calculates a List of all points where two Shapes intersect.

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

Calculates a List of all points where the Shape and a ShapeContour intersect.

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

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

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

Applies a boolean org.openrndr.shape.union operation between two Shapes.

Sources

Link copied to clipboard