Files
orx/orx-shapes/README.md
2025-08-28 22:07:06 +00:00

19 KiB

orx-shapes

Collection of 2D shape generators and modifiers.

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.

adjust-DemoAdjustContour01Kt

source code

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.

adjust-DemoAdjustContour02Kt

source code

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.

adjust-DemoAdjustContour03Kt

source code

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.

adjust-DemoAdjustContour04Kt

source code

adjust/DemoAdjustContour05

adjust-DemoAdjustContour05Kt

source code

adjust/DemoAdjustContour06

adjust-DemoAdjustContour06Kt

source code

adjust/DemoAdjustContour07

adjust-DemoAdjustContour07Kt

source code

adjust/DemoAdjustContour08

adjust-DemoAdjustContour08Kt

source code

adjust/DemoAdjustContour09

adjust-DemoAdjustContour09Kt

source code

adjust/DemoAdjustContourContinue01

adjust-DemoAdjustContourContinue01Kt

source code

alphashape/DemoAlphaShape

alphashape-DemoAlphaShapeKt

source code

arrangement/DemoArrangement01

arrangement-DemoArrangement01Kt

source code

arrangement/DemoArrangement02

arrangement-DemoArrangement02Kt

source code

arrangement/DemoArrangement04

arrangement-DemoArrangement04Kt

source code

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.

bezierpatch-DemoBezierPatch01Kt

source code

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.

bezierpatch-DemoBezierPatch02Kt

source code

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.

bezierpatch-DemoBezierPatch03Kt

source code

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.

bezierpatch-DemoBezierPatch04Kt

source code

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.

bezierpatch-DemoBezierPatch05Kt

source code

bezierpatch/DemoBezierPatch06

Shows how to

  • create a [bezierPatch] out of 4 curved Segment2D instances
  • apply an image texture to the patch using a shadeStyle

bezierpatch-DemoBezierPatch06Kt

source code

bezierpatch/DemoBezierPatchDrawer01

bezierpatch-DemoBezierPatchDrawer01Kt

source code

bezierpatch/DemoBezierPatchDrawer02

bezierpatch-DemoBezierPatchDrawer02Kt

source code

bezierpatch/DemoBezierPatchDrawer03

bezierpatch-DemoBezierPatchDrawer03Kt

source code

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.

bezierpatch-DemoBezierPatches01Kt

source code

blend/DemoContourBlend01

Demonstration of uniform contour blending

blend-DemoContourBlend01Kt

source code

blend/DemoContourBlend02

Demonstration of non-uniform contour blending

blend-DemoContourBlend02Kt

source code

frames/DemoFrames01

frames-DemoFrames01Kt

source code

hobbycurve/DemoHobbyCurve01

hobbycurve-DemoHobbyCurve01Kt

source code

hobbycurve/DemoHobbyCurve02

hobbycurve-DemoHobbyCurve02Kt

source code

hobbycurve/DemoHobbyCurve03

hobbycurve-DemoHobbyCurve03Kt

source code

hobbycurve/DemoHobbyCurve3D01

hobbycurve-DemoHobbyCurve3D01Kt

source code

operators/DemoRoundCorners01

operators-DemoRoundCorners01Kt

source code

ordering/DemoHilbertOrder01

ordering-DemoHilbertOrder01Kt

source code

ordering/DemoHilbertOrder02

ordering-DemoHilbertOrder02Kt

source code

path3d/DemoPath3DProjection

path3d-DemoPath3DProjectionKt

source code

primitives/DemoArc01

primitives-DemoArc01Kt

source code

primitives/DemoCircleInversion01

primitives-DemoCircleInversion01Kt

source code

primitives/DemoCircleInversion02

primitives-DemoCircleInversion02Kt

source code

primitives/DemoCircleInversion03

primitives-DemoCircleInversion03Kt

source code

primitives/DemoNet01

primitives-DemoNet01Kt

source code

primitives/DemoPulley01

primitives-DemoPulley01Kt

source code

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.

primitives-DemoRectangleDistribute01Kt

source code

primitives/DemoRectangleFitHorizontally

primitives-DemoRectangleFitHorizontallyKt

source code

primitives/DemoRectangleGrid01

primitives-DemoRectangleGrid01Kt

source code

primitives/DemoRectangleGrid02

primitives-DemoRectangleGrid02Kt

source code

primitives/DemoRectangleGrid03

primitives-DemoRectangleGrid03Kt

source code

primitives/DemoRectangleIntersection01

Demonstrate rectangle-rectangle intersection

primitives-DemoRectangleIntersection01Kt

source code

primitives/DemoRectangleIrregularGrid

primitives-DemoRectangleIrregularGridKt

source code

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.

primitives-DemoRectanglePlace01Kt

source code

primitives/DemoRegularPolygon

primitives-DemoRegularPolygonKt

source code

primitives/DemoRegularStar01

primitives-DemoRegularStar01Kt

source code

primitives/DemoRegularStar02

primitives-DemoRegularStar02Kt

source code

primitives/DemoRoundedRectangle

primitives-DemoRoundedRectangleKt

source code

primitives/DemoSplit01

primitives-DemoSplit01Kt

source code

primitives/DemoTear01

primitives-DemoTear01Kt

source code

rectify/DemoRectifiedContour01

rectify-DemoRectifiedContour01Kt

source code

rectify/DemoRectifiedContour02

rectify-DemoRectifiedContour02Kt

source code

rectify/DemoRectifiedContour03

rectify-DemoRectifiedContour03Kt

source code

rectify/DemoRectifiedContour04

rectify-DemoRectifiedContour04Kt

source code

rectify/DemoRectifiedPath3D01

rectify-DemoRectifiedPath3D01Kt

source code

text/DemoText01

text-DemoText01Kt

source code

tunni/DemoTunniAdjuster01

tunni-DemoTunniAdjuster01Kt

source code

tunni/DemoTunniPoint01

tunni-DemoTunniPoint01Kt

source code