Package org.openrndr.shape

Types

Link copied to clipboard
data class Circle(val center: Vector2, val radius: Double) : Movable, Scalable1D, ShapeProvider, ShapeContourProvider

Creates a Circle.

Link copied to clipboard
class CompoundBuilder
Link copied to clipboard
class ContourBuilder(multipleContours: Boolean)
Link copied to clipboard
data class ContourIntersection(    val a: ContourPoint,     val b: ContourPoint,     val position: Vector2)
Link copied to clipboard
data class ContourPoint(    val contour: ShapeContour,     val contourT: Double,     val segment: Segment,     val segmentT: Double,     val position: Vector2)

Representation of a point on a ShapeContour.

Link copied to clipboard
data class Ellipse(    val center: Vector2,     val xRadius: Double,     val yRadius: Double) : Movable, Scalable2D, ShapeProvider, ShapeContourProvider

Creates a new Ellipse.

Link copied to clipboard
enum FillRule : Enum<FillRule>
Link copied to clipboard
data class IntRectangle(    val corner: IntVector2,     val width: Int,     val height: Int)

Creates a new IntRectangle.

Link copied to clipboard
data class LineSegment(val start: Vector2, val end: Vector2) : LinearType<LineSegment> , ShapeProvider, ShapeContourProvider

A strictly linear 2D segment.

Link copied to clipboard
data class LineSegment3D(val start: Vector3, val end: Vector3)
Link copied to clipboard
interface Movable
Link copied to clipboard
class Path3D(val segments: List<Segment3D>, val closed: Boolean)
Link copied to clipboard
class Path3DBuilder
Link copied to clipboard
class PathProjection3D(    val segmentProjection: SegmentProjection3D,     val projection: Double,     val distance: Double,     val point: Vector3)
Link copied to clipboard
data class Rectangle(    val corner: Vector2,     val width: Double,     val height: Double = width) : Movable, Scalable2D, ShapeProvider, ShapeContourProvider

Creates a new axis-aligned Rectangle.

Link copied to clipboard
interface Scalable1D
Link copied to clipboard
interface Scalable2D : Scalable1D
Link copied to clipboard
class Segment : ShapeContourProvider

Creates a new Segment, which specifies a linear or a Bézier curve path between two anchor points (and up to two control points for curvature).

Link copied to clipboard
class Segment3D
Link copied to clipboard
class SegmentIntersection(    val a: SegmentPoint,     val b: SegmentPoint,     val position: Vector2)
Link copied to clipboard
enum SegmentJoin : Enum<SegmentJoin>
Link copied to clipboard
data class SegmentPoint(    val segment: Segment,     val segmentT: Double,     val position: Vector2)

Representation of a point on a Segment.

Link copied to clipboard
class SegmentProjection3D(    val segment: Segment3D,     val projection: Double,     val distance: Double,     val point: Vector3)
Link copied to clipboard
enum SegmentType : Enum<SegmentType>

Indicates the type of Segment.

Link copied to clipboard
class Shape(val contours: List<ShapeContour>) : ShapeProvider

A simple interface for managing a List of ShapeContour.

Link copied to clipboard
class ShapeBuilder

Shape builder class, used by shape

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

Link copied to clipboard
interface ShapeContourProvider

provider of ShapeContour

Link copied to clipboard
interface ShapeProvider

provider of Shape

Link copied to clipboard
enum ShapeTopology : Enum<ShapeTopology>

Indicates the Shape topology.

Link copied to clipboard
data class Triangle(    val x1: Vector2,     val x2: Vector2,     val x3: Vector2) : ShapeProvider, ShapeContourProvider

Creates a simple three-point polygon.

Link copied to clipboard
enum Winding : Enum<Winding>

Indicates the winding order of the ShapeContour.

Functions

Link copied to clipboard
fun Vector2.clamp(bounds: Rectangle): Vector2

Clamps a Vector2 within the bounds of the boundsRectangle.

Link copied to clipboard
fun compound(f: CompoundBuilder.() -> List<Shape>): List<Shape>
Link copied to clipboard
operator fun Shape.contains(v: Vector2): Boolean

Returns true if given Vector2 is inside the Shape.

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

Returns true if given point lies inside the ShapeContour.

Link copied to clipboard
fun contour(f: ContourBuilder.() -> Unit): ShapeContour

Build a contour

Link copied to clipboard
fun contours(f: ContourBuilder.() -> Unit): List<ShapeContour>

Build multiple org.openrndr.shape.contours

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

Applies a boolean difference operation between two Shapes.

fun ShapeContour.difference(other: Shape): Shape

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

@JvmName(name = "differenceIterative")
fun difference(from: List<Shape>, subtract: List<List<Shape>>): List<Shape>

Applies a boolean difference operation iteratively between a List of Shapes and a two-dimensional List of Shapes.

fun difference(from: List<Shape>, subtract: List<Shape>): List<Shape>

Applies a boolean difference operation between two Lists of Shapes.

fun difference(from: List<Shape>, subtract: Shape): List<Shape>

Applies a boolean difference operation between a List of Shapes and a Shape.

fun difference(from: List<Shape>, subtract: ShapeContour): List<Shape>

Applies a boolean difference operation between a List of Shapes and a ShapeContour.

fun difference(from: Shape, subtract: ShapeContour): Shape

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

fun difference(from: ShapeContour, subtract: Shape): Shape

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

fun difference(from: ShapeContour, subtract: ShapeContour): Shape

Applies a boolean difference operation between two ShapeContours.

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

Applies a boolean intersection operation between two Shapes.

fun ShapeContour.intersection(other: Shape): Shape

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

@JvmName(name = "intersectionIterative")
fun intersection(from: List<Shape>, with: List<List<Shape>>): List<Shape>

Applies a boolean intersection operation iteratively between a List of Shapes and a two-dimensional List of Shapes.

fun intersection(from: List<Shape>, with: List<Shape>): List<Shape>

Applies a boolean intersection operation between two Lists of Shapes.

fun intersection(from: List<Shape>, with: Shape): List<Shape>

Applies a boolean intersection operation between a List of Shapes and a Shape.

fun intersection(from: List<Shape>, with: ShapeContour): List<Shape>

Applies a boolean intersection operation between a List of Shapes and a ShapeContour.

fun intersection(from: Shape, with: ShapeContour): Shape

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

fun intersection(from: ShapeContour, with: Shape): Shape

Applies a boolean intersection operation between a ShapeContour and Shape.

fun intersection(from: ShapeContour, with: ShapeContour): Shape

Applies a boolean intersection operation between two ShapeContours.

fun intersection(    a: LineSegment,     b: LineSegment,     eps: Double = 0.0): Vector2
fun intersection(    a0: Vector2,     a1: Vector2,     b0: Vector2,     b1: Vector2,     eps: Double = 0.0): Vector2

Finds the intersection point between two LineSegments.

Link copied to clipboard
fun Segment.intersections(other: Segment): List<SegmentIntersection>
fun intersections(    a: Segment,     b: Segment,     vertexThreshold: Double = 1.0E-5): List<SegmentIntersection>

Calculates a List of all points where two Segments intersect.

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

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

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

Calculates a List of all points of where a Segment and a ShapeContour intersect.

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

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

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 ShapeContour.intersections(other: Segment): List<ContourIntersection>

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

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

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

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

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

fun intersections(a: Shape, b: Shape): List<ContourIntersection>

Calculates a List of all points of where paths intersect between the two Shapes.

fun intersections(    a: ShapeContour,     b: ShapeContour,     vertexThreshold: Double = 1.0E-5): List<ContourIntersection>

Calculates a List of all points of where paths intersect between two ShapeContours.

Link copied to clipboard
fun List<Vector2>.map(    sourceRectangle: Rectangle,     targetRectangle: Rectangle,     clamp: Boolean = false): List<Vector2>

Maps all elements in a List<Vector2> from sourceRectangle to targetRectangle. If clamp is true all elements are clamped within the bounds of targetRectangle.

fun Vector2.map(    sourceRectangle: Rectangle,     targetRectangle: Rectangle,     clamp: Boolean = false): Vector2

Remaps Vector2 from a position on the sourceRectangle to a proportionally equivalent position on the targetRectangle.

Link copied to clipboard
fun List<Double>.merge(f: (Double, Double) -> Boolean): List<Double>
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 path3D(f: Path3DBuilder.() -> Unit): Path3D
Link copied to clipboard
fun ShapeContour.removeLoops(attempts: Int = 0, reverseOrder: Boolean = false): ShapeContour
Link copied to clipboard
fun <T : LinearType<T>, EuclideanVector<T>> sampleEquidistant(segments: List<T>, count: Int): List<T>

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

Link copied to clipboard
fun shape(f: ShapeBuilder.() -> Unit): Shape

Build a shape

Link copied to clipboard
fun simplify(points: List<Vector2>, epsilon: Double): List<Vector2>

The Ramer–Douglas–Peucker algorithm, is an algorithm that decimates a curve composed of line segments to a similar curve with fewer points.

Link copied to clipboard
fun ShapeContour.split(cutters: List<ShapeContour>): List<ShapeContour>

Splits a ShapeContour with a List of ShapeContours.

fun ShapeContour.split(cutter: ShapeContour): List<ShapeContour>
fun split(from: ShapeContour, cutter: ShapeContour): List<ShapeContour>

Splits a ShapeContour with another ShapeContour.

fun split(shape: Shape, cutter: LineSegment): Pair<Shape, Shape>

Splits a Shape into two separate Shapes from given LineSegment.

fun split(from: ShapeContour, cutters: List<ShapeContour>): List<ShapeContour>

Splits a ShapeContour with all other ShapeContour in a List.

Link copied to clipboard
fun CatmullRomChain2.toContour(): ShapeContour

Converts chain to a ShapeContour.

Link copied to clipboard
fun CatmullRomChain3.toPath3D(): Path3D
Link copied to clipboard
fun CatmullRom2.toSegment(): Segment

Converts spline to a Segment.

fun CatmullRom3.toSegment(): Segment3D
Link copied to clipboard
fun triangulate(    shape: Shape,     distanceTolerance: Double = 0.5,     fillRule: FillRule = FillRule.NONZERO_WINDING): List<Vector2>

Triangulates a Shape into a List of triangle corner positions.

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

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

fun ShapeContour.union(other: Shape): Shape

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

@JvmName(name = "unionIterative")
fun union(from: List<Shape>, add: List<List<Shape>>): List<Shape>

Applies a boolean org.openrndr.shape.union operation iteratively between a List of Shapes and a two-dimensional List of Shapes.

fun union(from: List<Shape>, add: List<Shape>): List<Shape>

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

fun union(from: List<Shape>, add: Shape): List<Shape>

Applies a boolean org.openrndr.shape.union operation between a List of Shapes and a Shape.

fun union(from: List<Shape>, add: ShapeContour): List<Shape>

Applies a boolean org.openrndr.shape.union operation between a List of Shapes and a ShapeContour.

fun union(from: Shape, add: ShapeContour): Shape

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

fun union(from: ShapeContour, add: ShapeContour): Shape

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

Properties

Link copied to clipboard
@get:JvmName(name = "getVector2Bounds")
val List<Vector2>.bounds: Rectangle

Calculates Rectangle-bounds from a List of Vector2 instances.

@get:JvmName(name = "getRectangleBounds")
val List<Rectangle>.bounds: Rectangle

Calculates Rectangle-bounds for a list of Rectangle instances.

Link copied to clipboard
val List<Shape>.compound: Shape

Converts a List of Shape items into a single org.openrndr.shape.compound Shape.

Link copied to clipboard
val List<ShapeContour>.shape: Shape

Converts a List of ShapeContours to a single Shape.