PatchClip

class PatchClip(shape: Shape, val basis: Rectangle, val gridSize: Int = 32, distanceTolerance: Double = 0.5, fillRule: FillRule = FillRule.NON_ZERO, val clipToPatch: Boolean = true)(source)

The part of a Bezier patch inside a shape, tessellated: the counterpart of org.openrndr.extra.shapes.distort.envelope for the area of a shape instead of its outline. The x and y of the shape in the basis rectangle give the u and v on the patch, as they do for the envelope, so the rim of the surface follows the enveloped outline.

The tessellation is made in the u, v square, once: the shape is triangulated and its triangles are clipped to a grid of gridSize by gridSize cells, so that no triangle spans more than a cell and the surface bends with the patch inside the shape too. Neighbouring triangles share their corners, and the edges of the shape are split where they cross the grid, so the surface has no cracks. Since the tessellation does not depend on the control points of the patch, vertices can map it onto a patch that changes, frame by frame.

Parameters

shape

the shape, in the coordinates of basis; holes, like that of an O, are cut out by fillRule, and contours that overlap or cross themselves fill the shape once

basis

the rectangle of the shape that maps to the whole patch

gridSize

the number of grid cells along u and along v

distanceTolerance

the tolerance of the outline of the shape as it is sampled, in the coordinates of basis

fillRule

how the contours of the shape fill it

clipToPatch

true to keep only the part of the shape on the patch, where u and v are from 0 to 1; false to keep all of it, where the patch is extrapolated beyond its edges

Constructors

Link copied to clipboard
constructor(shape: Shape, basis: Rectangle, gridSize: Int = 32, distanceTolerance: Double = 0.5, fillRule: FillRule = FillRule.NON_ZERO, clipToPatch: Boolean = true)

Properties

Link copied to clipboard
val basis: Rectangle
Link copied to clipboard
val boundary: List<Pair<Vector2, Vector2>>

the edges of the rim of the surface in the u, v square, split where they cross the grid: every edge runs with the inside of the surface on its left

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

the triangles as indices into uvs, three for every triangle

Link copied to clipboard
val triangles: List<Vector2>

the triangles in the u, v square, three corners each, counterclockwise

Link copied to clipboard
val uvs: List<Vector2>

the distinct corners of the triangles, in the u, v square

Functions

Link copied to clipboard
fun vertices(patch: BezierPatch3D, thickness: Double = 0.0): List<PatchVertex>

The triangles of the surface on patch, three vertices each. With a thickness of 0 it is the surface itself, facing along the normal of the patch. Otherwise it is a solid between the surface and its offset by thickness along the normal (against it when negative): a face at either side, facing away from the solid, and walls along the rim, facing out. Triangles are wound counterclockwise seen from where their normals point. Texture coordinates are the u and v of the patch.