[orx-palette] Add ColorBrewer2, demos, update README (#363)

This commit is contained in:
Abe Pazos
2025-09-02 06:38:30 +02:00
committed by GitHub
parent af4c2b20d6
commit d1e5ba634d
14 changed files with 3057 additions and 66 deletions

View File

@@ -0,0 +1,68 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.palette.PaletteStudio
/**
* Demonstrates how to create a design using PaletteStudio.
* Press the `c` key to load a random palette.
*
*/
fun main() = application {
configure {
title = "Palette"
width = 720
height = 720
}
program {
val paletteStudio = PaletteStudio()
val colors = mutableListOf<ColorRGBa>()
fun fillColors() {
for (n in 0..36) {
when (n) {
12 -> paletteStudio.loadCollection(PaletteStudio.Collections.TWO)
24 -> paletteStudio.loadCollection(PaletteStudio.Collections.THREE)
}
val color = paletteStudio.colors.random()
colors.add(color)
}
}
keyboard.keyDown.listen {
if (it.name == "c") {
colors.clear()
fillColors()
}
}
fillColors()
extend {
drawer.clear(paletteStudio.background)
val size = 120.0
val radius = size / 2.0
for (x in 0 until 6) {
for (y in 0 until 6) {
val index = x + y * 6
val color = colors[index]
val x = size * x
val y = size * y
drawer.fill = color
drawer.stroke = color
if (index <= 11 || index > 23) {
drawer.circle(x + radius, y + radius, radius)
} else {
drawer.rectangle(x, y, size, size)
}
}
}
}
}
}