Package org.openrndr.shape

Types

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

Creates a Circle.

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

Representation of a point on a ShapeContour.

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

Creates a new Ellipse.

FillRule
Link copied to clipboard
enum FillRule : Enum<FillRule>
IndexedTriangulation
Link copied to clipboard
class IndexedTriangulation<T>(vertices: List<T>, triangles: List<Int>)

Indexed triangulation consisting of a list of vertices and triangle indices.

IntRectangle
Link copied to clipboard
common
data class IntRectangle(corner: IntVector2, width: Int, height: Int)

Creates a new IntRectangle.

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

A strictly linear 2D segment.

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

Creates a new Rectangle.

Scalable1D
Link copied to clipboard
common
interface Scalable1D
Scalable2D
Link copied to clipboard
common
interface Scalable2D : Scalable1D
Segment
Link copied to clipboard
common
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).

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

Representation of a point on a Segment.

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

Indicates the type of Segment.

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

A simple interface for managing a List of ShapeContour.

ShapeBuilder
Link copied to clipboard
common
class ShapeBuilder

Shape builder class, used by shape

ShapeContour
Link copied to clipboard
common
data class ShapeContour(segments: List<Segment>, closed: Boolean, polarity: YPolarity) : ShapeContourProvider

A List for managing a collection of Segments.

ShapeContourProvider
Link copied to clipboard
common
interface ShapeContourProvider

provider of ShapeContour

ShapeProvider
Link copied to clipboard
common
interface ShapeProvider

provider of Shape

ShapeTopology
Link copied to clipboard
common
enum ShapeTopology : Enum<ShapeTopology>

Indicates the Shape topology.

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

Creates a simple three-point polygon.

Winding
Link copied to clipboard
common
enum Winding : Enum<Winding>

Indicates the winding order of the ShapeContour.

Functions

compound
Link copied to clipboard
fun compound(f: CompoundBuilder.() -> List<Shape>): List<Shape>
contains
Link copied to clipboard
common
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.

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

Build a contour

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

Build multiple org.openrndr.shape.contours

cumsum
Link copied to clipboard
fun List<Int>.cumsum(): List<Int>

Cumulative sum of Ints in the List.

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

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

intersections
Link copied to clipboard
common
fun Segment.intersections(other: Segment): List<SegmentIntersection>
fun intersections(a: Segment, b: Segment, vertexThreshold: Double = 1E-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 = 1E-5): List<ContourIntersection>

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

intersects
Link copied to clipboard
common
fun intersects(a: Rectangle, b: Rectangle): Boolean

Determines whether or not rectangles a and b intersect.

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

merge
Link copied to clipboard
common
fun List<Double>.merge(f: (Double, Double) -> Boolean): List<Double>
offset
Link copied to clipboard
common
fun ShapeContour.offset(distance: Double, joinType: SegmentJoin = SegmentJoin.ROUND): ShapeContour

Offsets a ShapeContour's Segments by given distance.

path3D
Link copied to clipboard
common
fun path3D(f: Path3DBuilder.() -> Unit): Path3D
rectangleBounds
Link copied to clipboard
common
fun rectangleBounds(rectangles: List<Rectangle>): Rectangle

calculates Rectangle-bounds for a list of Rectangle instances

removeLoops
Link copied to clipboard
common
fun ShapeContour.removeLoops(attempts: Int = 0, reverseOrder: Boolean = false): ShapeContour
sampleEquidistant
Link copied to clipboard
common
fun sampleEquidistant(segments: List<Vector2>, count: Int): List<Vector2>
@JvmName(name = "sampleEquidistant3D")
fun sampleEquidistant(pieces: List<Vector3>, count: Int): List<Vector3>

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

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

Build a shape

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

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

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

Converts chain to a ShapeContour.

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

Converts spline to a Segment.

fun CatmullRom3.toSegment(): Segment3D
triangulate
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.

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

vector2Bounds
Link copied to clipboard
common
fun vector2Bounds(points: List<Vector2>): Rectangle

calculates Rectangle-bounds for a list of Vector2 instances

Properties

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

Calculates Rectangle-bounds from a List of Vector2 instances.

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

Calculates Rectangle-bounds for a list of Rectangle instances.

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

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

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

Converts a List of ShapeContours to a single Shape.