[orx-shapes] Demo comments
This commit is contained in:
@@ -13,56 +13,66 @@ import org.openrndr.shape.Circle
|
||||
import org.openrndr.shape.Rectangle
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
* Demonstrates how to render a grid of bezier patches that morph between a rectangle and
|
||||
* a rotated circle contour.
|
||||
* These shapes are transformed into bezier patches, and their colors are interpolated through a blend
|
||||
* factor calculated for each cell in the grid.
|
||||
*
|
||||
* The grid layout contains 4 columns and 4 rows with margins and gutters.
|
||||
* Each cell's center serves as the drawing position for a blended bezier patch.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val colors = listOf(
|
||||
listOf(
|
||||
ColorRGBa.PINK.toOKLABa(),
|
||||
ColorRGBa.PINK.toOKLABa(),
|
||||
ColorRGBa.PINK.toOKLABa(),
|
||||
ColorRGBa.PINK.toOKLABa()
|
||||
),
|
||||
listOf(
|
||||
ColorRGBa.RED.toOKLABa(),
|
||||
ColorRGBa.RED.toOKLABa(),
|
||||
ColorRGBa.RED.toOKLABa(),
|
||||
ColorRGBa.RED.toOKLABa()
|
||||
),
|
||||
listOf(
|
||||
ColorRGBa.BLUE.toOKLABa(),
|
||||
ColorRGBa.BLUE.toOKLABa(),
|
||||
ColorRGBa.BLUE.toOKLABa(),
|
||||
ColorRGBa.BLUE.toOKLABa()
|
||||
),
|
||||
listOf(
|
||||
ColorRGBa.WHITE.toOKLABa(),
|
||||
ColorRGBa.WHITE.toOKLABa(),
|
||||
ColorRGBa.WHITE.toOKLABa(),
|
||||
ColorRGBa.WHITE.toOKLABa()
|
||||
),
|
||||
)
|
||||
|
||||
val grid = drawer.bounds.grid(4, 4, marginX = 20.0, marginY = 20.0, gutterX = 10.0, gutterY = 10.0)
|
||||
|
||||
val cellWidth = grid[0][0].width
|
||||
val cellHeight = grid[0][0].height
|
||||
|
||||
val a = bezierPatch(Rectangle.fromCenter(Vector2.ZERO, cellWidth, cellHeight).contour)
|
||||
.withColors(colors)
|
||||
|
||||
val b = bezierPatch(
|
||||
Circle(Vector2.ZERO, min(cellWidth, cellHeight) / 2.0).contour.transform(
|
||||
buildTransform {
|
||||
rotate(Vector3.UNIT_Z, 45.0)
|
||||
}
|
||||
)
|
||||
).withColors(colors)
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
val colors = listOf(
|
||||
listOf(
|
||||
ColorRGBa.PINK.toOKLABa(),
|
||||
ColorRGBa.PINK.toOKLABa(),
|
||||
ColorRGBa.PINK.toOKLABa(),
|
||||
ColorRGBa.PINK.toOKLABa()
|
||||
),
|
||||
listOf(
|
||||
ColorRGBa.RED.toOKLABa(),
|
||||
ColorRGBa.RED.toOKLABa(),
|
||||
ColorRGBa.RED.toOKLABa(),
|
||||
ColorRGBa.RED.toOKLABa()
|
||||
),
|
||||
listOf(
|
||||
ColorRGBa.BLUE.toOKLABa(),
|
||||
ColorRGBa.BLUE.toOKLABa(),
|
||||
ColorRGBa.BLUE.toOKLABa(),
|
||||
ColorRGBa.BLUE.toOKLABa()
|
||||
),
|
||||
listOf(
|
||||
ColorRGBa.WHITE.toOKLABa(),
|
||||
ColorRGBa.WHITE.toOKLABa(),
|
||||
ColorRGBa.WHITE.toOKLABa(),
|
||||
ColorRGBa.WHITE.toOKLABa()
|
||||
),
|
||||
)
|
||||
|
||||
val grid = drawer.bounds.grid(4, 4, marginX = 20.0, marginY = 20.0, gutterX = 10.0, gutterY = 10.0)
|
||||
|
||||
val cellWidth = grid[0][0].width
|
||||
val cellHeight = grid[0][0].height
|
||||
|
||||
val a = bezierPatch(Rectangle.fromCenter(Vector2(0.0, 0.0), cellWidth, cellHeight).contour)
|
||||
.withColors(colors)
|
||||
|
||||
val b = bezierPatch(
|
||||
Circle(0.0, 0.0, min(cellWidth, cellHeight) / 2.0).contour.transform(
|
||||
buildTransform {
|
||||
rotate(Vector3.UNIT_Z, 45.0)
|
||||
}
|
||||
)
|
||||
).withColors(colors)
|
||||
|
||||
for (y in grid.indices) {
|
||||
for (x in grid[y].indices) {
|
||||
|
||||
Reference in New Issue
Block a user