Files
orx/orx-shapes/src/jvmDemo/kotlin/primitives/DemoRectangleGrid03.kt
Edwin Jakobs a7d878a710 [orx-shapes] Add irregular grid support and demo examples
This commit introduces `Rectangle.irregularGrid`, enabling the creation of grids with irregular spacing based on weights. New helper methods and properties for 2D rectangle lists, such as subgrid selection, bounds calculation, and random access, are also added. Additionally, two new demos showcase regular and irregular grid features.
2025-02-20 16:57:35 +01:00

40 lines
1.1 KiB
Kotlin

package primitives
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.shapes.primitives.bounds
import org.openrndr.extra.shapes.primitives.grid
import org.openrndr.extra.shapes.primitives.get
import org.openrndr.shape.bounds
fun main() = application {
configure {
width = 720
height = 720
}
program {
val grid = drawer.bounds.grid(12, 5)
extend {
drawer.stroke = ColorRGBa.WHITE
drawer.fill = null
drawer.rectangles(grid.flatten())
drawer.fill = ColorRGBa.GRAY.shade(0.4).opacify(0.5)
drawer.rectangle(grid[1..10, 0..4].bounds)
drawer.fill = ColorRGBa.PINK.shade(0.5).opacify(0.5)
drawer.rectangle(grid[5..6, 1].bounds)
drawer.fill = ColorRGBa.PINK.opacify(0.5)
drawer.rectangle(grid[2..5, 2].bounds)
drawer.fill = ColorRGBa.GRAY.opacify(0.5)
drawer.rectangle(grid[6..9, 2].bounds)
drawer.fill = ColorRGBa.GRAY.shade(0.5).opacify(0.5)
drawer.rectangle(grid[5..6, 3].bounds)
}
}
}