584 lines
19 KiB
Markdown
584 lines
19 KiB
Markdown
# orx-shapes
|
|
|
|
Collection of 2D shape generators and modifiers.
|
|
|
|
<!-- __demos__ -->
|
|
## Demos
|
|
### adjust/DemoAdjustContour01
|
|
|
|
Demonstrates how to use `adjustContour` to select and modify three vertices
|
|
in a circular contour. In OPENRNDR circles contain 4 cubic bézier
|
|
segments connecting 4 vertices.
|
|
|
|
On every animation frame the circular contour is created and transformed
|
|
using sines, cosines and the variable `seconds` for an animated effect.
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/adjust/DemoAdjustContour01.kt)
|
|
|
|
### adjust/DemoAdjustContour02
|
|
|
|
Demonstrates how to use `adjustContour` to select and remove vertex 0
|
|
from a circular contour, then select and animate the position and scale the new vertex 0.
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/adjust/DemoAdjustContour02.kt)
|
|
|
|
### adjust/DemoAdjustContour03
|
|
|
|
Demonstrates how to select and alter the edges of a rectangle.
|
|
|
|
The rectangle is a scaled-down version window bounds.
|
|
|
|
By default, the edges of a rectangular contour are linear, so the `edge.toCubic()` method
|
|
is called to make it possible to bend them.
|
|
|
|
Then various edges are selected one by one and transformed over time using operations like
|
|
scale, rotate, splitAt and moveBy.
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/adjust/DemoAdjustContour03.kt)
|
|
|
|
### adjust/DemoAdjustContour04
|
|
|
|
Demonstrates an `adjustContour` animated effect where edge 0 of a contour
|
|
is replaced by a point sampled on that edge. The specific edge point oscillates between
|
|
0.0 (at the start) and 1.0 (at the end) using a cosine and the `seconds` variable.
|
|
|
|
The base contour used for the effect alternates every second
|
|
between a rectangular and a circular contour.
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/adjust/DemoAdjustContour04.kt)
|
|
|
|
### adjust/DemoAdjustContour05
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/adjust/DemoAdjustContour05.kt)
|
|
|
|
### adjust/DemoAdjustContour06
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/adjust/DemoAdjustContour06.kt)
|
|
|
|
### adjust/DemoAdjustContour07
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/adjust/DemoAdjustContour07.kt)
|
|
|
|
### adjust/DemoAdjustContour08
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/adjust/DemoAdjustContour08.kt)
|
|
|
|
### adjust/DemoAdjustContour09
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/adjust/DemoAdjustContour09.kt)
|
|
|
|
### adjust/DemoAdjustContourContinue01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/adjust/DemoAdjustContourContinue01.kt)
|
|
|
|
### alphashape/DemoAlphaShape
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/alphashape/DemoAlphaShape.kt)
|
|
|
|
### arrangement/DemoArrangement01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/arrangement/DemoArrangement01.kt)
|
|
|
|
### arrangement/DemoArrangement02
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/arrangement/DemoArrangement02.kt)
|
|
|
|
### arrangement/DemoArrangement04
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/arrangement/DemoArrangement04.kt)
|
|
|
|
### bezierpatch/DemoBezierPatch01
|
|
|
|
Shows how to
|
|
- create a [bezierPatch] out of 4 [LineSegment]
|
|
- create a sub-patch out of a [bezierPatch]
|
|
- create horizontal and vertical [ShapeContour]s out of [bezierPatch]es
|
|
|
|
The created contours are horizontal and vertical in "bezier-patch space" but
|
|
are rendered deformed following the shape of the bezier patch.
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/bezierpatch/DemoBezierPatch01.kt)
|
|
|
|
### bezierpatch/DemoBezierPatch02
|
|
|
|
Shows how to create a [bezierPatch] out of a
|
|
closed [ShapeContour] with 4 curved segments.
|
|
|
|
Calling [Circle.contour] is one way of producing
|
|
such a contour with vertices at the cardinal points
|
|
but one can manually create any other 4-segment closed contour
|
|
to use in bezier patches.
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/bezierpatch/DemoBezierPatch02.kt)
|
|
|
|
### bezierpatch/DemoBezierPatch03
|
|
|
|
Shows how to distort [ShapeContour]s using a [bezierPatch]
|
|
|
|
In this case the contours are regular stars and the bezier patch
|
|
is created using a circular contour with the required 4 segments.
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/bezierpatch/DemoBezierPatch03.kt)
|
|
|
|
### bezierpatch/DemoBezierPatch04
|
|
|
|
Shows how to get positions and gradient values of those positions
|
|
from a [bezierPatch]
|
|
|
|
You can think of bezierPatch.position() as requesting points
|
|
in a wavy flag (the bezier patch) using normalized uv coordinates.
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/bezierpatch/DemoBezierPatch04.kt)
|
|
|
|
### bezierpatch/DemoBezierPatch05
|
|
|
|
Shows how to
|
|
- create a [bezierPatch] out of 4 [Segment3D]
|
|
- create a sub-patch out of a [bezierPatch]
|
|
- create horizontal and vertical [Path3D]s out of [bezierPatch]es
|
|
- add colors to a [bezierPatch]
|
|
- draw a [bezierPatch] surface
|
|
|
|
The created contours are horizontal and vertical in "bezier-patch space" but
|
|
are rendered deformed following the shape of the bezier patch.
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/bezierpatch/DemoBezierPatch05.kt)
|
|
|
|
### bezierpatch/DemoBezierPatch06
|
|
|
|
Shows how to
|
|
- create a [bezierPatch] out of 4 curved Segment2D instances
|
|
- apply an image texture to the patch using a shadeStyle
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/bezierpatch/DemoBezierPatch06.kt)
|
|
|
|
### bezierpatch/DemoBezierPatchDrawer01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/bezierpatch/DemoBezierPatchDrawer01.kt)
|
|
|
|
### bezierpatch/DemoBezierPatchDrawer02
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/bezierpatch/DemoBezierPatchDrawer02.kt)
|
|
|
|
### bezierpatch/DemoBezierPatchDrawer03
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/bezierpatch/DemoBezierPatchDrawer03.kt)
|
|
|
|
### bezierpatch/DemoBezierPatches01
|
|
|
|
Shows how to create a [bezierPatch] out of a
|
|
closed [ShapeContour] with 4 curved segments.
|
|
|
|
Calling [Circle.contour] is one way of producing
|
|
such a contour with vertices at the cardinal points
|
|
but one can manually create any other 4-segment closed contour
|
|
to use in bezier patches.
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/bezierpatch/DemoBezierPatches01.kt)
|
|
|
|
### blend/DemoContourBlend01
|
|
|
|
Demonstration of uniform contour blending
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/blend/DemoContourBlend01.kt)
|
|
|
|
### blend/DemoContourBlend02
|
|
|
|
Demonstration of non-uniform contour blending
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/blend/DemoContourBlend02.kt)
|
|
|
|
### frames/DemoFrames01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/frames/DemoFrames01.kt)
|
|
|
|
### hobbycurve/DemoHobbyCurve01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/hobbycurve/DemoHobbyCurve01.kt)
|
|
|
|
### hobbycurve/DemoHobbyCurve02
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/hobbycurve/DemoHobbyCurve02.kt)
|
|
|
|
### hobbycurve/DemoHobbyCurve03
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/hobbycurve/DemoHobbyCurve03.kt)
|
|
|
|
### hobbycurve/DemoHobbyCurve3D01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/hobbycurve/DemoHobbyCurve3D01.kt)
|
|
|
|
### operators/DemoRoundCorners01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/operators/DemoRoundCorners01.kt)
|
|
|
|
### ordering/DemoHilbertOrder01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/ordering/DemoHilbertOrder01.kt)
|
|
|
|
### ordering/DemoHilbertOrder02
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/ordering/DemoHilbertOrder02.kt)
|
|
|
|
### path3d/DemoPath3DProjection
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/path3d/DemoPath3DProjection.kt)
|
|
|
|
### primitives/DemoArc01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoArc01.kt)
|
|
|
|
### primitives/DemoCircleInversion01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoCircleInversion01.kt)
|
|
|
|
### primitives/DemoCircleInversion02
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoCircleInversion02.kt)
|
|
|
|
### primitives/DemoCircleInversion03
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoCircleInversion03.kt)
|
|
|
|
### primitives/DemoNet01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoNet01.kt)
|
|
|
|
### primitives/DemoPulley01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoPulley01.kt)
|
|
|
|
### primitives/DemoRectangleDistribute01
|
|
|
|
of rectangles, which are generated and manipulated based on time and random parameters. The application
|
|
follows these steps:
|
|
|
|
1. Initializes a random generator seeded with the elapsed seconds since the start of the program.
|
|
2. Creates a sequence of rectangles using the `uniformSub` function to generate random sub-rectangles
|
|
within the bounding rectangle of the canvas.
|
|
3. Distributes the generated rectangles horizontally within the canvas using the `distributeHorizontally` method.
|
|
4. Aligns the rectangles vertically according to their position in relation to the bounding rectangle
|
|
and a dynamic anchor point derived from the cosine of elapsed time.
|
|
5. Renders the rectangles on the canvas in the output window.
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoRectangleDistribute01.kt)
|
|
|
|
### primitives/DemoRectangleFitHorizontally
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoRectangleFitHorizontally.kt)
|
|
|
|
### primitives/DemoRectangleGrid01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoRectangleGrid01.kt)
|
|
|
|
### primitives/DemoRectangleGrid02
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoRectangleGrid02.kt)
|
|
|
|
### primitives/DemoRectangleGrid03
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoRectangleGrid03.kt)
|
|
|
|
### primitives/DemoRectangleIntersection01
|
|
|
|
Demonstrate rectangle-rectangle intersection
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoRectangleIntersection01.kt)
|
|
|
|
### primitives/DemoRectangleIrregularGrid
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoRectangleIrregularGrid.kt)
|
|
|
|
### primitives/DemoRectanglePlace01
|
|
|
|
Demo for rendering a 10x10 grid of rectangles within the bounds
|
|
of the canvas. Each rectangle's position is calculated relative to its anchors, filling the entire
|
|
canvas with evenly placed items.
|
|
|
|
The rectangles are drawn using the default white color. The `place` function is applied to each
|
|
rectangle to position them dynamically based on their relative anchor points within the bounding area.
|
|
|
|
This serves as a demonstration of positioning and rendering shapes in a structured grid layout.
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoRectanglePlace01.kt)
|
|
|
|
### primitives/DemoRegularPolygon
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoRegularPolygon.kt)
|
|
|
|
### primitives/DemoRegularStar01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoRegularStar01.kt)
|
|
|
|
### primitives/DemoRegularStar02
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoRegularStar02.kt)
|
|
|
|
### primitives/DemoRoundedRectangle
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoRoundedRectangle.kt)
|
|
|
|
### primitives/DemoSplit01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoSplit01.kt)
|
|
|
|
### primitives/DemoTear01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/primitives/DemoTear01.kt)
|
|
|
|
### rectify/DemoRectifiedContour01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/rectify/DemoRectifiedContour01.kt)
|
|
|
|
### rectify/DemoRectifiedContour02
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/rectify/DemoRectifiedContour02.kt)
|
|
|
|
### rectify/DemoRectifiedContour03
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/rectify/DemoRectifiedContour03.kt)
|
|
|
|
### rectify/DemoRectifiedContour04
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/rectify/DemoRectifiedContour04.kt)
|
|
|
|
### rectify/DemoRectifiedPath3D01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/rectify/DemoRectifiedPath3D01.kt)
|
|
|
|
### text/DemoText01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/text/DemoText01.kt)
|
|
|
|
### tunni/DemoTunniAdjuster01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/tunni/DemoTunniAdjuster01.kt)
|
|
|
|
### tunni/DemoTunniPoint01
|
|
|
|
|
|
|
|

|
|
|
|
[source code](src/jvmDemo/kotlin/tunni/DemoTunniPoint01.kt)
|