Files
orx/orx-shapes/src/jvmDemo/kotlin/primitives/DemoRectangleGrid02.kt
Abe Pazos c8f7dd52c6 Demos: ensure all use fun main() = application {
- Adjust some demo window sizes.
- Replace Random.double by Double.uniform
- Tweak some demos so screenshots look more interesting
2025-01-26 20:57:04 +01:00

40 lines
1.2 KiB
Kotlin

package primitives
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.noise.Random
import org.openrndr.extra.shapes.primitives.grid
fun main() = application {
// Try changing the resolution. The design will use the available space.
configure {
width = 800
height = 400
}
program {
// By specifying the cell size we make sure the design will
// contain squares, independently of the window size and its
// aspect ratio.
val grid = drawer.bounds.grid(
50.0, 50.0,
20.0, 20.0, 20.0, 20.0
).flatten()
val grid2 = grid.map { rect ->
// Each of these inner grids will occupy the available space
// in the parent grid cells. Notice how we don't specify cell
// sizes here but counts instead (between 1 and 3 columns and
// rows)
val count = Random.int(1, 4)
rect.grid(count, count, 5.0, 5.0, 5.0, 5.0).flatten()
}.flatten().filter { Random.bool(0.5) }
extend {
drawer.clear(ColorRGBa.PINK)
drawer.rectangles(grid)
drawer.fill = ColorRGBa.BLACK
drawer.rectangles(grid2)
}
}
}