Demos: ensure 720px wide, reduce indentation

openrndr-demos, orx-color, orx-jumpflood, orx-no-clear
This commit is contained in:
Abe Pazos
2025-01-25 13:30:18 +01:00
parent f84bf69713
commit fc4f7275fb
74 changed files with 1314 additions and 1293 deletions

View File

@@ -49,6 +49,56 @@ for (c in cs blend (width / 40)) {
Two color spaces are added: `ColorHSLUVa` and `ColorHPLUVa`, they are an implementation of the colorspaces presented at [hsluv.org](http://www.hsluv.org)
<!-- __demos__ -->
## Demos
### colormap/DemoSpectralZucconiColormap
[source code](src/jvmDemo/kotlin/colormap/DemoSpectralZucconiColormap.kt)
![colormap-DemoSpectralZucconiColormapKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colormap-DemoSpectralZucconiColormapKt.png)
### colormap/DemoSpectralZucconiColormapPhrase
[source code](src/jvmDemo/kotlin/colormap/DemoSpectralZucconiColormapPhrase.kt)
![colormap-DemoSpectralZucconiColormapPhraseKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colormap-DemoSpectralZucconiColormapPhraseKt.png)
### colormap/DemoSpectralZucconiColormapPlot
[source code](src/jvmDemo/kotlin/colormap/DemoSpectralZucconiColormapPlot.kt)
![colormap-DemoSpectralZucconiColormapPlotKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colormap-DemoSpectralZucconiColormapPlotKt.png)
### colormap/DemoTurboColormap
[source code](src/jvmDemo/kotlin/colormap/DemoTurboColormap.kt)
![colormap-DemoTurboColormapKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colormap-DemoTurboColormapKt.png)
### colormap/DemoTurboColormapPhrase
[source code](src/jvmDemo/kotlin/colormap/DemoTurboColormapPhrase.kt)
![colormap-DemoTurboColormapPhraseKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colormap-DemoTurboColormapPhraseKt.png)
### colormap/DemoTurboColormapPlot
[source code](src/jvmDemo/kotlin/colormap/DemoTurboColormapPlot.kt)
![colormap-DemoTurboColormapPlotKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colormap-DemoTurboColormapPlotKt.png)
### colorRange/DemoColorRange01
[source code](src/jvmDemo/kotlin/colorRange/DemoColorRange01.kt)
![colorRange-DemoColorRange01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colorRange-DemoColorRange01Kt.png)
### colorRange/DemoColorRange02
[source code](src/jvmDemo/kotlin/colorRange/DemoColorRange02.kt)
![colorRange-DemoColorRange02Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colorRange-DemoColorRange02Kt.png)
### colorRange/DemoColorRange03
[source code](src/jvmDemo/kotlin/colorRange/DemoColorRange03.kt)
![colorRange-DemoColorRange03Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colorRange-DemoColorRange03Kt.png)
### colorRange/DemoColorRange04
[source code](src/jvmDemo/kotlin/colorRange/DemoColorRange04.kt)
![colorRange-DemoColorRange04Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/colorRange-DemoColorRange04Kt.png)
### DemoColorPalette01
[source code](src/jvmDemo/kotlin/DemoColorPalette01.kt)
@@ -69,26 +119,6 @@ Two color spaces are added: `ColorHSLUVa` and `ColorHPLUVa`, they are an impleme
![DemoColorPlane02Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoColorPlane02Kt.png)
### DemoColorRange01
[source code](src/jvmDemo/kotlin/DemoColorRange01.kt)
![DemoColorRange01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoColorRange01Kt.png)
### DemoColorRange02
[source code](src/jvmDemo/kotlin/DemoColorRange02.kt)
![DemoColorRange02Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoColorRange02Kt.png)
### DemoColorRange03
[source code](src/jvmDemo/kotlin/DemoColorRange03.kt)
![DemoColorRange03Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoColorRange03Kt.png)
### DemoColorRange04
[source code](src/jvmDemo/kotlin/DemoColorRange04.kt)
![DemoColorRange04Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoColorRange04Kt.png)
### DemoColorSequence01
[source code](src/jvmDemo/kotlin/DemoColorSequence01.kt)
@@ -109,21 +139,6 @@ Two color spaces are added: `ColorHSLUVa` and `ColorHPLUVa`, they are an impleme
![DemoFettePalette02Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoFettePalette02Kt.png)
### DemoHistogram01
[source code](src/jvmDemo/kotlin/DemoHistogram01.kt)
![DemoHistogram01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoHistogram01Kt.png)
### DemoHistogram02
[source code](src/jvmDemo/kotlin/DemoHistogram02.kt)
![DemoHistogram02Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoHistogram02Kt.png)
### DemoHistogram03
[source code](src/jvmDemo/kotlin/DemoHistogram03.kt)
![DemoHistogram03Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoHistogram03Kt.png)
### DemoHSLUV01
[source code](src/jvmDemo/kotlin/DemoHSLUV01.kt)
@@ -149,37 +164,22 @@ Two color spaces are added: `ColorHSLUVa` and `ColorHPLUVa`, they are an impleme
![DemoOKHSV01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoOKHSV01Kt.png)
### DemoSpectralZucconiColormap
[source code](src/jvmDemo/kotlin/DemoSpectralZucconiColormap.kt)
![DemoSpectralZucconiColormapKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoSpectralZucconiColormapKt.png)
### DemoSpectralZucconiColormapPhrase
[source code](src/jvmDemo/kotlin/DemoSpectralZucconiColormapPhrase.kt)
![DemoSpectralZucconiColormapPhraseKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoSpectralZucconiColormapPhraseKt.png)
### DemoSpectralZucconiColormapPlot
[source code](src/jvmDemo/kotlin/DemoSpectralZucconiColormapPlot.kt)
![DemoSpectralZucconiColormapPlotKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoSpectralZucconiColormapPlotKt.png)
### DemoTurboColormap
[source code](src/jvmDemo/kotlin/DemoTurboColormap.kt)
![DemoTurboColormapKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoTurboColormapKt.png)
### DemoTurboColormapPhrase
[source code](src/jvmDemo/kotlin/DemoTurboColormapPhrase.kt)
![DemoTurboColormapPhraseKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoTurboColormapPhraseKt.png)
### DemoTurboColormapPlot
[source code](src/jvmDemo/kotlin/DemoTurboColormapPlot.kt)
![DemoTurboColormapPlotKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoTurboColormapPlotKt.png)
### DemoXSLUV01
[source code](src/jvmDemo/kotlin/DemoXSLUV01.kt)
![DemoXSLUV01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/DemoXSLUV01Kt.png)
### histogram/DemoHistogram01
[source code](src/jvmDemo/kotlin/histogram/DemoHistogram01.kt)
![histogram-DemoHistogram01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/histogram-DemoHistogram01Kt.png)
### histogram/DemoHistogram02
[source code](src/jvmDemo/kotlin/histogram/DemoHistogram02.kt)
![histogram-DemoHistogram02Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/histogram-DemoHistogram02Kt.png)
### histogram/DemoHistogram03
[source code](src/jvmDemo/kotlin/histogram/DemoHistogram03.kt)
![histogram-DemoHistogram03Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-color/images/histogram-DemoHistogram03Kt.png)

View File

@@ -11,7 +11,10 @@ import org.openrndr.extra.color.spaces.*
* Demonstrates the creation of color palettes using various available methods
*/
fun main() = application {
configure { }
configure {
width = 720
height = 540
}
program {
// HueShiftableColor:
// HPLuv HSL HSV LCHab LCHuv XSL XSV XSLuv HSLuv OKHSL OKHSV OKLCH
@@ -27,34 +30,33 @@ fun main() = application {
palette0.forEachIndexed { i, c ->
drawer.fill = c
drawer.circle(100.0 + i * 40.0, 80.0, 40.0)
drawer.circle(100.0 + i * 50.0, 80.0, 50.0)
}
palette1.forEachIndexed { i, c ->
drawer.fill = c
drawer.circle(100.0 + i * 40.0, 180.0, 40.0)
drawer.circle(100.0 + i * 50.0, 200.0, 50.0)
}
palette2.forEachIndexed { i, c ->
drawer.fill = c
drawer.circle(380.0 + i * 40.0, 180.0, 40.0)
drawer.circle(440.0 + i * 50.0, 200.0, 50.0)
}
palette3.forEachIndexed { i, c ->
drawer.fill = c
drawer.circle(100.0 + i * 40.0, 280.0, 40.0)
drawer.circle(100.0 + i * 50.0, 320.0, 50.0)
}
palette4.forEachIndexed { i, c ->
drawer.fill = c
drawer.circle(350.0 + i * 40.0, 280.0, 40.0)
drawer.circle(400.0 + i * 50.0, 320.0, 50.0)
}
palette5.forEachIndexed { i, c ->
drawer.fill = c
drawer.circle(100.0 + i * 40.0, 380.0, 40.0)
drawer.circle(100.0 + i * 50.0, 440.0, 50.0)
}
}
}
}

View File

@@ -11,6 +11,10 @@ import org.openrndr.extra.color.tools.shadeLuminosity
* an increased dynamic range.
*/
fun main() = application {
configure {
width = 720
height = 360
}
program {
val count = 8
val palette = RGB.PINK.analogous<HSLuv>(360.0, count).mapIndexed { i, c ->

View File

@@ -7,80 +7,75 @@ import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.math.Vector3
import kotlin.math.cos
fun main() {
application {
configure {
width = 800
height = 800
fun main() = application {
configure {
width = 720
height = 720
}
program {
val mesh = sphereMesh(8, 8, radius = 0.1)
}
program {
val mesh = sphereMesh(8, 8, radius = 0.1)
val instanceData = vertexBuffer(
vertexFormat {
attribute("instanceColor", VertexElementType.VECTOR4_FLOAT32)
attribute("instancePosition", VertexElementType.VECTOR3_FLOAT32)
},
90 * 100
)
println(extensions.size)
extend(Orbital())
val instanceData = vertexBuffer(
vertexFormat {
attribute("instanceColor", VertexElementType.VECTOR4_FLOAT32)
attribute("instancePosition", VertexElementType.VECTOR3_FLOAT32)
},
90 * 100
)
println(extensions.size)
extend(Orbital())
extend {
drawer.clear(ColorRGBa.WHITE)
drawer.stroke = null
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
extend {
drawer.clear(ColorRGBa.WHITE)
drawer.stroke = null
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
instanceData.put {
for (hue in 0 until 360 step 4) {
for (chroma in 0 until 100 step 1) {
val lch = ColorOKLCHa(cos(seconds * 0.1) * 0.5 + 0.5, chroma / 100.0, hue.toDouble())
val srgb = lch.toRGBa().toSRGB().clip()
write(srgb)
write(Vector3((srgb.r - 0.5) * 10.0, (srgb.g - 0.5) * 10.0, (srgb.b - 0.5) * 10.0))
}
instanceData.put {
for (hue in 0 until 360 step 4) {
for (chroma in 0 until 100 step 1) {
val lch = ColorOKLCHa(cos(seconds * 0.1) * 0.5 + 0.5, chroma / 100.0, hue.toDouble())
val srgb = lch.toRGBa().toSRGB().clip()
write(srgb)
write(Vector3((srgb.r - 0.5) * 10.0, (srgb.g - 0.5) * 10.0, (srgb.b - 0.5) * 10.0))
}
}
drawer.isolated {
drawer.shadeStyle = shadeStyle {
}
drawer.isolated {
drawer.shadeStyle = shadeStyle {
vertexTransform = """
vertexTransform = """
x_position += i_instancePosition;
""".trimIndent()
fragmentTransform = """
fragmentTransform = """
x_fill = vi_instanceColor;
""".trimIndent()
}
drawer.vertexBufferInstances(listOf(mesh), listOf(instanceData), DrawPrimitive.TRIANGLES, 90 * 100)
}
drawer.stroke = ColorRGBa.BLACK.opacify(0.25)
drawer.strokeWeight = 10.0
drawer.lineSegments(
listOf(
Vector3(-5.0, -5.0, -5.0), Vector3(5.0, -5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, 5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, 5.0, -5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, -5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, -5.0, 5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, 5.0, -5.0), Vector3(5.0, 5.0, 5.0),
)
)
drawer.vertexBufferInstances(listOf(mesh), listOf(instanceData), DrawPrimitive.TRIANGLES, 90 * 100)
}
drawer.stroke = ColorRGBa.BLACK.opacify(0.25)
drawer.strokeWeight = 10.0
drawer.lineSegments(
listOf(
Vector3(-5.0, -5.0, -5.0), Vector3(5.0, -5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, 5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, 5.0, -5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, -5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, -5.0, 5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, 5.0, -5.0), Vector3(5.0, 5.0, 5.0),
)
)
}
}
}
}

View File

@@ -7,73 +7,71 @@ import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.math.Vector3
import kotlin.math.cos
fun main() {
application {
configure {
width = 800
height = 800
}
program {
val mesh = sphereMesh(8, 8, radius = 0.1)
fun main() = application {
configure {
width = 720
height = 720
}
program {
val mesh = sphereMesh(8, 8, radius = 0.1)
val instanceData = vertexBuffer(
vertexFormat {
attribute("instanceColor", VertexElementType.VECTOR4_FLOAT32)
attribute("instancePosition", VertexElementType.VECTOR3_FLOAT32)
},
100 * 100
)
extend(Orbital())
extend {
drawer.clear(ColorRGBa.WHITE)
val instanceData = vertexBuffer(
vertexFormat {
attribute("instanceColor", VertexElementType.VECTOR4_FLOAT32)
attribute("instancePosition", VertexElementType.VECTOR3_FLOAT32)
},
100 * 100
)
extend(Orbital())
extend {
drawer.clear(ColorRGBa.WHITE)
drawer.stroke = null
drawer.stroke = null
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
instanceData.put {
for (lumo in 0 until 100 step 1) {
for (chroma in 0 until 100 step 1) {
val lch = ColorOKLCHa(lumo / 100.0, chroma / 100.0, cos(seconds * 0.1) * 360.0)
val srgb = lch.toRGBa().toSRGB().clip()
write(srgb)
write(Vector3((srgb.r - 0.5) * 10.0, (srgb.g - 0.5) * 10.0, (srgb.b - 0.5) * 10.0))
}
instanceData.put {
for (lumo in 0 until 100 step 1) {
for (chroma in 0 until 100 step 1) {
val lch = ColorOKLCHa(lumo / 100.0, chroma / 100.0, cos(seconds * 0.1) * 360.0)
val srgb = lch.toRGBa().toSRGB().clip()
write(srgb)
write(Vector3((srgb.r - 0.5) * 10.0, (srgb.g - 0.5) * 10.0, (srgb.b - 0.5) * 10.0))
}
}
drawer.isolated {
drawer.shadeStyle = shadeStyle {
vertexTransform = """
}
drawer.isolated {
drawer.shadeStyle = shadeStyle {
vertexTransform = """
x_position += i_instancePosition;
""".trimIndent()
fragmentTransform = """
fragmentTransform = """
x_fill = vi_instanceColor;
""".trimIndent()
}
drawer.vertexBufferInstances(listOf(mesh), listOf(instanceData), DrawPrimitive.TRIANGLES, 90 * 100)
}
drawer.stroke = ColorRGBa.BLACK.opacify(0.25)
drawer.strokeWeight = 10.0
drawer.lineSegments(
listOf(
Vector3(-5.0, -5.0, -5.0), Vector3(5.0, -5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, 5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, 5.0, -5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, -5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, -5.0, 5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, 5.0, -5.0), Vector3(5.0, 5.0, 5.0),
)
)
drawer.vertexBufferInstances(listOf(mesh), listOf(instanceData), DrawPrimitive.TRIANGLES, 90 * 100)
}
drawer.stroke = ColorRGBa.BLACK.opacify(0.25)
drawer.strokeWeight = 10.0
drawer.lineSegments(
listOf(
Vector3(-5.0, -5.0, -5.0), Vector3(5.0, -5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, 5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, 5.0, -5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, -5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, -5.0, 5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, 5.0, -5.0), Vector3(5.0, 5.0, 5.0),
)
)
}
}
}
}

View File

@@ -1,52 +0,0 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.loadFont
import org.openrndr.extra.color.spaces.*
import org.openrndr.extra.color.palettes.rangeTo
fun main() {
application {
configure {
height = 30 + 50 * 11 // row count
}
program {
extend {
drawer.clear(ColorRGBa.WHITE)
val colorA = ColorRGBa.BLUE
val colorB = ColorRGBa.PINK
val stepCount = 25
val allSteps = listOf(
"RGB" to (colorA..colorB blend stepCount),
"RGB linear" to (colorA.toLinear()..colorB.toLinear() blend stepCount),
"HSV" to (colorA..colorB.toHSVa() blend stepCount),
"Lab" to (colorA.toLABa()..colorB.toLABa() blend stepCount),
"LCh(ab)" to (colorA.toLCHABa()..colorB.toLCHABa() blend stepCount),
"OKLab" to (colorA.toOKLABa()..colorB.toOKLABa() blend stepCount),
"OKLCh" to (colorA.toOKLCHa()..colorB.toOKLCHa() blend stepCount),
"OKHSV" to (colorA.toOKHSVa()..colorB.toOKHSVa() blend stepCount),
"OKHSL" to (colorA.toOKHSLa()..colorB.toOKHSLa() blend stepCount),
"HSLUV" to (colorA.toHSLUVa()..colorB.toHSLUVa() blend stepCount),
"XSLUV" to (colorA.toXSLUVa()..colorB.toXSLUVa() blend stepCount),
)
drawer.stroke = null
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
drawer.translate(20.0, 20.0)
for ((label, steps) in allSteps) {
drawer.fill = ColorRGBa.GRAY.shade(0.25)
drawer.text(label, 0.0, 24.0)
for (i in steps.indices) {
drawer.fill = steps[i].toSRGB()
drawer.rectangle(100.0 + i * 20.0, 0.0, 20.0, 40.0)
}
drawer.translate(0.0, 50.0)
}
}
}
}
}

View File

@@ -1,87 +0,0 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.DrawPrimitive
import org.openrndr.draw.isolated
import org.openrndr.draw.loadFont
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.color.palettes.rangeTo
import org.openrndr.extra.color.spaces.toHSLUVa
import org.openrndr.extra.color.spaces.toOKLABa
import org.openrndr.extra.color.spaces.toOKLCHa
import org.openrndr.extra.color.spaces.toXSLUVa
import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.math.Vector3
fun main() {
application {
configure {
width = 800
height = 800
}
program {
val mesh = sphereMesh(8, 8, radius = 0.1)
extend(Orbital())
extend {
drawer.clear(ColorRGBa.WHITE)
val colorA = ColorRGBa.BLUE.toHSVa().shiftHue(seconds * 40.0).toRGBa()
val colorB = ColorRGBa.PINK.toHSVa().shiftHue(-seconds * 34.0).toRGBa()
val stepCount = 25
val allSteps = listOf(
"RGB" to (colorA..colorB blend stepCount),
"RGB linear" to (colorA.toLinear()..colorB.toLinear() blend stepCount),
"HSV" to (colorA..colorB.toHSVa() blend stepCount),
"Lab" to (colorA.toLABa()..colorB.toLABa() blend stepCount),
"LCh(ab)" to (colorA.toLCHABa()..colorB.toLCHABa() blend stepCount),
"OKLab" to (colorA.toOKLABa()..colorB.toOKLABa() blend stepCount),
"OKLCh" to (colorA.toOKLCHa()..colorB.toOKLCHa() blend stepCount),
"HSLUV" to (colorA.toHSLUVa()..colorB.toHSLUVa() blend stepCount),
"XSLUV" to (colorA.toXSLUVa()..colorB.toXSLUVa() blend stepCount),
)
drawer.stroke = null
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
for ((_, steps) in allSteps) {
for (i in steps.indices) {
val srgb = steps[i].toSRGB().clip()
drawer.fill = srgb
drawer.isolated {
drawer.translate((srgb.r - 0.5) * 10.0, (srgb.g - 0.5) * 10.0, (srgb.b - 0.5) * 10.0)
drawer.vertexBuffer(mesh, DrawPrimitive.TRIANGLES)
}
}
val positions = steps.map {
val l = it.toSRGB().clip()
Vector3((l.r - 0.5) * 10.0, (l.g - 0.5) * 10.0, (l.b - 0.5) * 10.0)
}
drawer.stroke = ColorRGBa.BLACK.opacify(0.25)
drawer.strokeWeight = 10.0
drawer.lineStrip(positions)
}
drawer.lineSegments(
listOf(
Vector3(-5.0, -5.0, -5.0), Vector3(5.0, -5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, 5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, 5.0, -5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, -5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, -5.0, 5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, 5.0, -5.0), Vector3(5.0, 5.0, 5.0),
)
)
}
}
}
}

View File

@@ -24,48 +24,46 @@ import org.openrndr.math.Vector3
* - Applying a custom fragment shader with a palette-based shading style.
* - Rendering a grid of 3D spheres, each transformed and rotated to create a dynamic pattern.
*/
fun main() {
application {
configure {
width = 720
height = 720
}
program {
val cs = ColorSequence(
listOf(
0.0 to ColorRGBa.PINK,
0.25 to ColorRGBa.ORANGE.toOKLABa(),
0.27 to ColorRGBa.WHITE.toOKLABa(),
0.32 to ColorRGBa.BLUE,
1.0 to ColorRGBa.MEDIUM_AQUAMARINE
)
fun main() = application {
configure {
width = 720
height = 720
}
program {
val cs = ColorSequence(
listOf(
0.0 to ColorRGBa.PINK,
0.25 to ColorRGBa.ORANGE.toOKLABa(),
0.27 to ColorRGBa.WHITE.toOKLABa(),
0.32 to ColorRGBa.BLUE,
1.0 to ColorRGBa.MEDIUM_AQUAMARINE
)
val palette = cs.toColorBuffer(drawer, 256, 16)
val sphere = sphereMesh(sides = 48, segments = 48)
)
val palette = cs.toColorBuffer(drawer, 256, 16)
val sphere = sphereMesh(sides = 48, segments = 48)
extend(Orbital()) {
fov = 50.0
eye = Vector3(0.0, 0.0, 13.0)
}
extend {
drawer.shadeStyle = shadeStyle {
fragmentTransform = """
extend(Orbital()) {
fov = 50.0
eye = Vector3(0.0, 0.0, 13.0)
}
extend {
drawer.shadeStyle = shadeStyle {
fragmentTransform = """
float d = normalize(va_normal).z;
x_fill = texture(p_palette, vec2(1.0-d, 0.0));
""".trimIndent()
parameter("palette", palette)
}
for (j in -2..2) {
for (i in -2..2) {
drawer.isolated {
drawer.translate(i * 2.0, j * 2.0, 0.0)
drawer.rotate(Vector3.UNIT_Y, j * 30.0)
drawer.rotate(Vector3.UNIT_X, i * 30.0)
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
}
parameter("palette", palette)
}
for (j in -2..2) {
for (i in -2..2) {
drawer.isolated {
drawer.translate(i * 2.0, j * 2.0, 0.0)
drawer.rotate(Vector3.UNIT_Y, j * 30.0)
drawer.rotate(Vector3.UNIT_X, i * 30.0)
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
}
}
}
}
}
}
}

View File

@@ -4,36 +4,34 @@ import org.openrndr.extra.color.spaces.toOKHSVa
import org.openrndr.extra.color.statistics.deltaE76
import org.openrndr.math.Polar
fun main() {
application {
configure {
width = 720
height = 720
}
program {
extend {
drawer.clear(ColorRGBa.BLACK)
drawer.fill = null
drawer.stroke = ColorRGBa.WHITE.opacify(0.2)
for (i in 10 until 270 step 10) {
drawer.circle(drawer.bounds.center, i.toDouble())
}
fun main() = application {
configure {
width = 720
height = 720
}
program {
extend {
drawer.clear(ColorRGBa.BLACK)
drawer.fill = null
drawer.stroke = ColorRGBa.WHITE.opacify(0.2)
for (i in 10 until 270 step 10) {
drawer.circle(drawer.bounds.center, i.toDouble())
}
drawer.stroke = null
drawer.stroke = null
val startColor = ColorRGBa.RED.toOKHSVa().shiftHue(seconds*36.0).toRGBa()
drawer.circles {
for (j in 99 downTo 0) {
for (i in 0 until 360 step 10) {
val color = startColor.toOKHSVa().shiftHue(i.toDouble()).saturate(j / 99.0).toRGBa()
val distance = color.deltaE76(startColor)
val p = Polar(seconds * 36.0 + i.toDouble(), distance).cartesian + drawer.bounds.center
fill = color
circle(p, 2.0)
}
val startColor = ColorRGBa.RED.toOKHSVa().shiftHue(seconds * 36.0).toRGBa()
drawer.circles {
for (j in 99 downTo 0) {
for (i in 0 until 360 step 10) {
val color = startColor.toOKHSVa().shiftHue(i.toDouble()).saturate(j / 99.0).toRGBa()
val distance = color.deltaE76(startColor)
val p = Polar(seconds * 36.0 + i.toDouble(), distance).cartesian + drawer.bounds.center
fill = color
circle(p, 2.0)
}
}
}
}
}
}
}

View File

@@ -6,81 +6,79 @@ import org.openrndr.extra.color.fettepalette.generateColorRamp
import org.openrndr.math.Vector2
import kotlin.random.Random
fun main() {
application {
configure {
width = 720
height = 720
}
fun main() = application {
configure {
width = 720
height = 720
}
program {
val total = 9
extend {
val ramp = generateColorRamp(
total = total,
centerHue = (mouse.position.x / width) * 360.0,
curveMethod = Lamé,
hueCycle = mouse.position.y / height,
curveAccent = 0.0,
offsetTint = 0.01,
offsetShade = 0.01,
tintShadeHueShift = 0.01,
offsetCurveModTint = 0.03,
offsetCurveModShade = 0.03,
minSaturationLight = Vector2.ZERO,
maxSaturationLight = Vector2.ONE,
useOK = true
)
fun rampSquare(ramp: ColorRamp, random: Random, position: Vector2, width: Double) {
drawer.isolated {
drawer.fill = ramp.baseColors.random(random).toRGBa()
drawer.stroke = null
drawer.rectangle(position, width, width)
drawer.fill = ramp.lightColors.random(random).toRGBa()
drawer.rectangle(position + Vector2(width / 4.0, width / 4.0), width / 4.0, width / 2.0)
val dc = ramp.darkColors.shuffled(random).take(2)
drawer.fill = dc[0].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 4.0), width / 4.0, width / 4.0)
drawer.fill = dc[1].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 2.0), width / 4.0, width / 4.0)
}
}
program {
val total = 9
extend {
val ramp = generateColorRamp(
total = total,
centerHue = (mouse.position.x / width) * 360.0,
curveMethod = Lamé,
hueCycle = mouse.position.y / height,
curveAccent = 0.0,
offsetTint = 0.01,
offsetShade = 0.01,
tintShadeHueShift = 0.01,
offsetCurveModTint = 0.03,
offsetCurveModShade = 0.03,
minSaturationLight = Vector2.ZERO,
maxSaturationLight = Vector2.ONE,
useOK = true
)
fun rampSquare(ramp: ColorRamp, random: Random, position: Vector2, width: Double) {
drawer.isolated {
for ((index, i) in ramp.lightColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 20.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.baseColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 70.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.darkColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 120.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.fill = ramp.baseColors.random(random).toRGBa()
drawer.stroke = null
drawer.rectangle(position, width, width)
val random = Random(seconds.toInt())
rampSquare(ramp, random, Vector2(180.0, 180.0), 360.0)
drawer.fill = ramp.lightColors.random(random).toRGBa()
drawer.rectangle(position + Vector2(width / 4.0, width / 4.0), width / 4.0, width / 2.0)
val dc = ramp.darkColors.shuffled(random).take(2)
drawer.fill = dc[0].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 4.0), width / 4.0, width / 4.0)
drawer.fill = dc[1].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 2.0), width / 4.0, width / 4.0)
}
}
drawer.isolated {
for ((index, i) in ramp.lightColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 20.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.baseColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 70.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.darkColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 120.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
val random = Random(seconds.toInt())
rampSquare(ramp, random, Vector2(180.0, 180.0), 360.0)
}
}
}
}

View File

@@ -8,70 +8,68 @@ import org.openrndr.extra.gui.addTo
import org.openrndr.math.Vector2
import kotlin.random.Random
fun main() {
application {
configure {
width = 720
height = 720
}
fun main() = application {
configure {
width = 720
height = 720
}
program {
val gui = GUI()
val parameters = ColorRampParameters()
parameters.addTo(gui)
extend(gui)
extend {
val ramp = generateColorRamp(parameters)
fun rampSquare(ramp: ColorRamp, random: Random, position: Vector2, width: Double) {
drawer.isolated {
drawer.fill = ramp.baseColors.random(random).toRGBa()
drawer.stroke = null
drawer.rectangle(position, width, width)
drawer.fill = ramp.lightColors.random(random).toRGBa()
drawer.rectangle(position + Vector2(width / 4.0, width / 4.0), width / 4.0, width / 2.0)
val dc = ramp.darkColors.shuffled(random).take(2)
drawer.fill = dc[0].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 4.0), width / 4.0, width / 4.0)
drawer.fill = dc[1].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 2.0), width / 4.0, width / 4.0)
}
}
drawer.translate(200.0, 0.0)
program {
val gui = GUI()
val parameters = ColorRampParameters()
parameters.addTo(gui)
extend(gui)
extend {
val ramp = generateColorRamp(parameters)
fun rampSquare(ramp: ColorRamp, random: Random, position: Vector2, width: Double) {
drawer.isolated {
for ((index, i) in ramp.lightColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 20.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.baseColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 70.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.darkColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 120.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.fill = ramp.baseColors.random(random).toRGBa()
drawer.stroke = null
drawer.rectangle(position, width, width)
val random = Random(seconds.toInt())
rampSquare(ramp, random, Vector2(20.0, 180.0), 360.0)
drawer.fill = ramp.lightColors.random(random).toRGBa()
drawer.rectangle(position + Vector2(width / 4.0, width / 4.0), width / 4.0, width / 2.0)
val dc = ramp.darkColors.shuffled(random).take(2)
drawer.fill = dc[0].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 4.0), width / 4.0, width / 4.0)
drawer.fill = dc[1].toRGBa()
drawer.rectangle(position + Vector2(width / 2.0, width / 2.0), width / 4.0, width / 4.0)
}
}
drawer.translate(200.0, 0.0)
drawer.isolated {
for ((index, i) in ramp.lightColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 20.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.baseColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 70.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
drawer.isolated {
for ((index, i) in ramp.darkColors.withIndex()) {
drawer.stroke = null
drawer.fill = i.toRGBa()
drawer.rectangle(20.0, 120.0, 50.0, 50.0)
drawer.translate(50.0, 0.0)
}
}
val random = Random(seconds.toInt())
rampSquare(ramp, random, Vector2(20.0, 180.0), 360.0)
}
}
}
}

View File

@@ -10,37 +10,41 @@ import org.openrndr.extra.color.spaces.ColorHSLUVa
import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
fun main() {
application {
program {
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 26.0)
extend {
drawer.stroke = null
drawer.clear(rgb(0.3))
val s = mouse.position.x / width
val l = mouse.position.y / height
for (a in 0 until 360 step 12) {
val pos = Vector2(0.0, 110.0)
drawer.isolated {
translate(bounds.center)
rotate(a * 1.0)
fun main() = application {
configure {
width = 720
height = 540
}
program {
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 26.0)
extend {
drawer.stroke = null
drawer.clear(rgb(0.3))
val s = mouse.position.x / width
val l = mouse.position.y / height
for (a in 0 until 360 step 12) {
val pos = Vector2(0.0, 110.0)
drawer.isolated {
translate(bounds.center)
rotate(a * 1.0)
fill = ColorHSLUVa(a * 1.0, s, l).toRGBa().toSRGB()
rectangle(Rectangle(pos * 1.2, 40.0, 300.0))
fill = ColorHSLUVa(a * 1.0, s, l).toRGBa().toSRGB()
rectangle(Rectangle(pos * 1.2, 40.0, 300.0))
fill = ColorHSLa(a * 1.0, s, l).toRGBa()
rectangle(Rectangle.fromCenter(pos, 30.0, 60.0))
}
fill = ColorHSLa(a * 1.0, s, l).toRGBa()
rectangle(Rectangle.fromCenter(pos, 30.0, 60.0))
}
drawer.fontMap = font
drawer.fill = if(l > 0.8) ColorRGBa.BLACK else ColorRGBa.WHITE
drawer.text("HSLa", width * 0.48, height * 0.73)
drawer.text("HSLUVa", width * 0.8, height * 0.52)
drawer.text("hue: 0 to 360, " +
}
drawer.fontMap = font
drawer.fill = if (l > 0.8) ColorRGBa.BLACK else ColorRGBa.WHITE
drawer.text("HSLa", width * 0.48, height * 0.73)
drawer.text("HSLUVa", width * 0.8, height * 0.52)
drawer.text(
"hue: 0 to 360, " +
"saturation: ${String.format("%.02f", s)}, " +
"lightness: ${String.format("%.02f", l)}",
30.0, 460.0)
}
30.0, height - 30.0
)
}
}
}
}

View File

@@ -7,41 +7,40 @@ import org.openrndr.math.Polar
import org.openrndr.math.Vector2
import kotlin.math.sqrt
fun main() {
application {
configure {
width = 720
height = 720
fun main() = application {
configure {
width = 720
height = 720
}
val g = Math.PI * 2.0 * (1.0 - 1.0 / 1.61803398875)
fun phyllotaxis(count: Int) = sequence {
for (i in 0 until count) {
yield(Polar(Math.toDegrees(i * 1.0), g * i))
}
}
val g = Math.PI * 2.0 * (1.0 - 1.0 / 1.61803398875)
fun phyllotaxis(count: Int) = sequence {
for (i in 0 until count) {
yield(Polar(Math.toDegrees(i * 1.0), g * i))
}
}
program {
extend {
drawer.clear(ColorRGBa.GRAY)
val color = ColorRGBa.RED
val hc = color.toHSLUVa()
drawer.stroke = null
drawer.strokeWeight = 0.0
program {
extend {
drawer.clear(ColorRGBa.GRAY)
val color = ColorRGBa.RED
val hc = color.toHSLUVa()
drawer.stroke = null
drawer.strokeWeight = 0.0
val count = 400
val bobRadius = 20.0
val count = 400
val bobRadius = 20.0
for (i in phyllotaxis(count)) {
val h = i.theta
val s = i.radius / (count * g)
for (l in 9 downTo 0) {
val position = i.cartesian / (count * g) * (width / 2.0 - bobRadius) + Vector2(width / 2.0, height / 2.0)
drawer.fill = hc.shiftHue(h).saturate(s).shade((9 - l) / 4.5).toRGBa().toSRGB()
drawer.circle(position, sqrt(s) * 20.0 * l / 9.0)
}
for (i in phyllotaxis(count)) {
val h = i.theta
val s = i.radius / (count * g)
for (l in 9 downTo 0) {
val position =
i.cartesian / (count * g) * (width / 2.0 - bobRadius) + Vector2(width / 2.0, height / 2.0)
drawer.fill = hc.shiftHue(h).saturate(s).shade((9 - l) / 4.5).toRGBa().toSRGB()
drawer.circle(position, sqrt(s) * 20.0 * l / 9.0)
}
}
}
}
}
}

View File

@@ -5,37 +5,35 @@ import org.openrndr.extra.color.spaces.OKHSV
import org.openrndr.extra.color.tools.mixHue
import org.openrndr.extra.color.tools.withHue
fun main() {
application {
configure {
width = 800
height = 800
}
program {
extend {
val seedColor = ColorRGBa.PINK
val targetHue = seconds*100.0
fun main() = application {
configure {
width = 720
height = 720
}
program {
extend {
val seedColor = ColorRGBa.PINK
val targetHue = seconds * 100.0
val rows = 10
val columns = 12
val rows = 10
val columns = 12
val cellWidth = width / columns.toDouble()
val cellHeight = height / rows.toDouble()
val cellWidth = width / columns.toDouble()
val cellHeight = height / rows.toDouble()
drawer.stroke = null
for (j in 0 until 10) {
drawer.isolated {
for (i in 0 until columns) {
drawer.fill = seedColor
.withHue<OKHSV>(i * 360.0 / columns)
.mixHue<OKHSV>(targetHue, j / (rows.toDouble()-1.0))
drawer.rectangle(0.0, 0.0, cellWidth, cellHeight)
drawer.translate(cellWidth, 0.0)
}
drawer.stroke = null
for (j in 0 until 10) {
drawer.isolated {
for (i in 0 until columns) {
drawer.fill = seedColor
.withHue<OKHSV>(i * 360.0 / columns)
.mixHue<OKHSV>(targetHue, j / (rows.toDouble() - 1.0))
drawer.rectangle(0.0, 0.0, cellWidth, cellHeight)
drawer.translate(cellWidth, 0.0)
}
drawer.translate(0.0, cellHeight)
}
drawer.translate(0.0, cellHeight)
}
}
}
}
}

View File

@@ -3,41 +3,33 @@ import org.openrndr.color.ColorRGBa
import org.openrndr.draw.isolated
import org.openrndr.extra.color.mixing.mixSpectral
import org.openrndr.extra.color.spaces.OKHSV
import org.openrndr.extra.color.spaces.OKLab
import org.openrndr.extra.color.tools.saturate
import org.openrndr.extra.color.tools.shadeLuminosity
import org.openrndr.extra.color.tools.shiftHue
fun main() {
application {
configure {
width = 800
height = 800
}
program {
fun main() = application {
configure {
width = 720
height = 720
}
program {
extend {
val a = ColorRGBa.BLUE.shiftHue<OKHSV>(0.0).saturate<OKHSV>(0.3).shadeLuminosity<OKLab>(0.3)
val b = ColorRGBa.BLUE.shiftHue<OKHSV>(60.0).saturate<OKHSV>(0.8)
extend {
drawer.isolated {
for (i in 0 until 60) {
val c = mixSpectral(a, b, i / 59.0, 0.0, 0.0).toSRGB()
drawer.fill = c
drawer.stroke = null
drawer.rectangle(0.0, 0.0, width / 60.0, 1.0 * height)
for (j in 0 until 60) {
val p = 3.0
val a = ColorRGBa.BLUE.shiftHue<OKHSV>(j * p)
val b = ColorRGBa.BLUE.shiftHue<OKHSV>(j * p + 180.0)
drawer.translate(width / 60.0, 0.0)
drawer.isolated {
for (i in 0 until 60) {
val c = mixSpectral(a, b, i / 59.0, 0.0, 0.0).toSRGB()
drawer.fill = c
drawer.stroke = null
drawer.rectangle(0.0, 0.0, width/60.0, 0.5 * height/60.0)
drawer.fill = a.mix(b, i / 59.0)
drawer.rectangle(0.0, 0.5 * height, width/60.0, 0.5 * height/60.0)
drawer.translate(width/60.0, 0.0)
}
}
drawer.translate(0.0, 0.5 * height/60.0)
}
}
drawer.translate(0.0, 0.5 * height / 60.0)
}
}
}
}

View File

@@ -1,11 +1,18 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.color.rgb
import org.openrndr.extra.color.spaces.ColorOKHSLa
import org.openrndr.extra.color.spaces.ColorOKHSVa
fun main() = application {
configure {
width = 720
height = 160
}
program {
extend {
drawer.clear(rgb(0.2))
val c = ColorRGBa.GREEN
val okhsv = ColorOKHSVa.fromColorRGBa(c)
val hsv = c.toHSVa()

View File

@@ -3,15 +3,22 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.color.spaces.ColorXSLUVa
import org.openrndr.extra.color.spaces.toHSLUVa
import org.openrndr.math.Polar
import org.openrndr.shape.contour
fun main() {
fun main() = application {
configure {
width = 720
height = 720
}
class Arc(val start: Double, val radius: Double, val length: Double, val height: Double) {
fun split(offset: Double = 0.0): List<Arc> {
val hl = length / 2.0
return listOf(Arc(start, radius + offset, hl, height), Arc(start + hl, radius + offset, hl, height))
return listOf(
Arc(start, radius + offset, hl, height),
Arc(start + hl, radius + offset, hl, height)
)
}
val contour
@@ -31,30 +38,22 @@ fun main() {
this + flatMap { it.split(it.height) }.split(depth - 1)
}
application {
configure {
width = 720
height = 720
}
program {
val arcs = (0..4).map { Arc(it * 90.0 - 45.0, 50.0, 90.0, 50.0) }.split(5)
program {
val arcs = (0..4).map { Arc(it * 90.0 - 45.0, 50.0, 90.0, 50.0) }.split(5)
extend {
drawer.clear(ColorRGBa.GRAY)
val color = ColorRGBa.RED
val hc = color.toHSLUVa()
drawer.stroke = ColorRGBa.BLACK
drawer.strokeWeight = 1.0
drawer.translate(drawer.bounds.center)
val l = if (System.getProperty("takeScreenshot") == "true") 0.7 else mouse.position.y / height
val s = if (System.getProperty("takeScreenshot") == "true") 1.0 else mouse.position.x / width
for (arc in arcs) {
val xsluv = ColorXSLUVa(arc.start + arc.length / 2.0, s, l, 1.0)
drawer.fill = xsluv.toRGBa()
drawer.contour(arc.contour)
}
extend {
drawer.clear(ColorRGBa.GRAY)
val color = ColorRGBa.RED
drawer.stroke = ColorRGBa.BLACK
drawer.strokeWeight = 1.0
drawer.translate(drawer.bounds.center)
val l = if (System.getProperty("takeScreenshot") == "true") 0.7 else mouse.position.y / height
val s = if (System.getProperty("takeScreenshot") == "true") 1.0 else mouse.position.x / width
for (arc in arcs) {
val xsluv = ColorXSLUVa(arc.start + arc.length / 2.0, s, l, 1.0)
drawer.fill = xsluv.toRGBa()
drawer.contour(arc.contour)
}
}
}
}
}

View File

@@ -1,3 +1,5 @@
package colorRange
// Comparison of color lists generated by interpolating from
// PINK to BLUE in different color models
@@ -10,6 +12,10 @@ import org.openrndr.math.map
import org.openrndr.shape.Rectangle
fun main() = application {
configure {
width = 720
height = 540
}
program {
val numColors = 10
val colorLists = listOf(

View File

@@ -1,3 +1,5 @@
package colorRange
// Create a colorSequence with multiple color models
import org.openrndr.application
@@ -6,6 +8,10 @@ import org.openrndr.extra.color.palettes.colorSequence
import org.openrndr.extra.color.spaces.toHSLUVa
fun main() = application {
configure {
width = 720
height = 360
}
program {
extend {
val cs = colorSequence(0.0 to ColorRGBa.PINK,

View File

@@ -0,0 +1,53 @@
package colorRange
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.loadFont
import org.openrndr.extra.color.palettes.rangeTo
import org.openrndr.extra.color.spaces.*
fun main() = application {
configure {
width = 720
height = 30 + 50 * 11 // row count
}
program {
extend {
drawer.clear(ColorRGBa.WHITE)
val colorA = ColorRGBa.BLUE
val colorB = ColorRGBa.PINK
val stepCount = 25
val allSteps = listOf(
"RGB" to (colorA..colorB blend stepCount),
"RGB linear" to (colorA.toLinear()..colorB.toLinear() blend stepCount),
"HSV" to (colorA..colorB.toHSVa() blend stepCount),
"Lab" to (colorA.toLABa()..colorB.toLABa() blend stepCount),
"LCh(ab)" to (colorA.toLCHABa()..colorB.toLCHABa() blend stepCount),
"OKLab" to (colorA.toOKLABa()..colorB.toOKLABa() blend stepCount),
"OKLCh" to (colorA.toOKLCHa()..colorB.toOKLCHa() blend stepCount),
"OKHSV" to (colorA.toOKHSVa()..colorB.toOKHSVa() blend stepCount),
"OKHSL" to (colorA.toOKHSLa()..colorB.toOKHSLa() blend stepCount),
"HSLUV" to (colorA.toHSLUVa()..colorB.toHSLUVa() blend stepCount),
"XSLUV" to (colorA.toXSLUVa()..colorB.toXSLUVa() blend stepCount),
)
drawer.stroke = null
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
drawer.translate(20.0, 20.0)
for ((label, steps) in allSteps) {
drawer.fill = ColorRGBa.GRAY.shade(0.25)
drawer.text(label, 0.0, 24.0)
for (i in steps.indices) {
drawer.fill = steps[i].toSRGB()
drawer.rectangle(100.0 + i * 20.0, 0.0, 20.0, 40.0)
}
drawer.translate(0.0, 50.0)
}
}
}
}

View File

@@ -0,0 +1,87 @@
package colorRange
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.DrawPrimitive
import org.openrndr.draw.isolated
import org.openrndr.draw.loadFont
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.color.palettes.rangeTo
import org.openrndr.extra.color.spaces.toHSLUVa
import org.openrndr.extra.color.spaces.toOKLABa
import org.openrndr.extra.color.spaces.toOKLCHa
import org.openrndr.extra.color.spaces.toXSLUVa
import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.math.Vector3
fun main() = application {
configure {
width = 720
height = 720
}
program {
val mesh = sphereMesh(8, 8, radius = 0.1)
extend(Orbital())
extend {
drawer.clear(ColorRGBa.WHITE)
val colorA = ColorRGBa.BLUE.toHSVa().shiftHue(seconds * 40.0).toRGBa()
val colorB = ColorRGBa.PINK.toHSVa().shiftHue(-seconds * 34.0).toRGBa()
val stepCount = 25
val allSteps = listOf(
"RGB" to (colorA..colorB blend stepCount),
"RGB linear" to (colorA.toLinear()..colorB.toLinear() blend stepCount),
"HSV" to (colorA..colorB.toHSVa() blend stepCount),
"Lab" to (colorA.toLABa()..colorB.toLABa() blend stepCount),
"LCh(ab)" to (colorA.toLCHABa()..colorB.toLCHABa() blend stepCount),
"OKLab" to (colorA.toOKLABa()..colorB.toOKLABa() blend stepCount),
"OKLCh" to (colorA.toOKLCHa()..colorB.toOKLCHa() blend stepCount),
"HSLUV" to (colorA.toHSLUVa()..colorB.toHSLUVa() blend stepCount),
"XSLUV" to (colorA.toXSLUVa()..colorB.toXSLUVa() blend stepCount),
)
drawer.stroke = null
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
for ((_, steps) in allSteps) {
for (i in steps.indices) {
val srgb = steps[i].toSRGB().clip()
drawer.fill = srgb
drawer.isolated {
drawer.translate((srgb.r - 0.5) * 10.0, (srgb.g - 0.5) * 10.0, (srgb.b - 0.5) * 10.0)
drawer.vertexBuffer(mesh, DrawPrimitive.TRIANGLES)
}
}
val positions = steps.map {
val l = it.toSRGB().clip()
Vector3((l.r - 0.5) * 10.0, (l.g - 0.5) * 10.0, (l.b - 0.5) * 10.0)
}
drawer.stroke = ColorRGBa.BLACK.opacify(0.25)
drawer.strokeWeight = 10.0
drawer.lineStrip(positions)
}
drawer.lineSegments(
listOf(
Vector3(-5.0, -5.0, -5.0), Vector3(5.0, -5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, 5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, 5.0, -5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, 5.0, -5.0),
Vector3(-5.0, -5.0, 5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, -5.0, 5.0), Vector3(5.0, 5.0, 5.0),
Vector3(-5.0, -5.0, -5.0), Vector3(-5.0, -5.0, 5.0),
Vector3(5.0, -5.0, -5.0), Vector3(5.0, -5.0, 5.0),
Vector3(-5.0, 5.0, -5.0), Vector3(-5.0, 5.0, 5.0),
Vector3(5.0, 5.0, -5.0), Vector3(5.0, 5.0, 5.0),
)
)
}
}
}

View File

@@ -1,9 +1,15 @@
package colormap
import org.openrndr.application
import org.openrndr.extra.color.colormaps.spectralZucconi6
import org.openrndr.extra.noise.fastFloor
import kotlin.math.sin
fun main() = application {
configure {
width = 720
height = 360
}
program {
extend {
drawer.stroke = null

View File

@@ -1,9 +1,15 @@
package colormap
import org.openrndr.application
import org.openrndr.draw.shadeStyle
import org.openrndr.extra.color.colormaps.ColormapPhraseBook
import org.openrndr.extra.shaderphrases.preprocess
fun main() = application {
configure {
width = 720
height = 360
}
program {
ColormapPhraseBook.register()
val style = shadeStyle {
@@ -11,10 +17,8 @@ fun main() = application {
fragmentTransform = "x_fill.rgb = spectral_zucconi6(c_boundsPosition.x);"
}
extend {
drawer.run {
shadeStyle = style
rectangle(bounds)
}
drawer.shadeStyle = style
drawer.rectangle(drawer.bounds)
}
}
}

View File

@@ -1,3 +1,5 @@
package colormap
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.shadeStyle
@@ -7,22 +9,28 @@ import org.openrndr.extra.shaderphrases.preprocess
import org.openrndr.math.Vector2
fun main() = application {
configure {
width = 720
height = 360
}
program {
ColormapPhraseBook.register()
val backgroundStyle = shadeStyle {
fragmentPreamble = "#pragma import colormap.spectral_zucconi6".preprocess()
fragmentTransform = "x_fill.rgb = spectral_zucconi6(c_boundsPosition.x);"
}
fun getColormapPoints(
block: ColorRGBa.() -> Double
) = List(width) { x ->
Vector2(
x = x.toDouble(),
y = height.toDouble()
- block(spectralZucconi6(x / width.toDouble()))
* height.toDouble()
x.toDouble(),
height.toDouble()
- block(spectralZucconi6(x / width.toDouble()))
* height.toDouble()
)
}
val redPoints = getColormapPoints { r }
val greenPoints = getColormapPoints { g }
val bluePoints = getColormapPoints { b }

View File

@@ -1,9 +1,15 @@
package colormap
import org.openrndr.application
import org.openrndr.extra.color.colormaps.turboColormap
import org.openrndr.extra.noise.fastFloor
import kotlin.math.sin
fun main() = application {
configure {
width = 720
height = 360
}
program {
extend {
drawer.stroke = null

View File

@@ -1,9 +1,15 @@
package colormap
import org.openrndr.application
import org.openrndr.draw.shadeStyle
import org.openrndr.extra.color.colormaps.ColormapPhraseBook
import org.openrndr.extra.shaderphrases.preprocess
fun main() = application {
configure {
width = 720
height = 360
}
program {
ColormapPhraseBook.register()
val style = shadeStyle {
@@ -11,10 +17,8 @@ fun main() = application {
fragmentTransform = "x_fill.rgb = turbo_colormap(c_boundsPosition.x);"
}
extend {
drawer.run {
shadeStyle = style
rectangle(bounds)
}
drawer.shadeStyle = style
drawer.rectangle(drawer.bounds)
}
}
}

View File

@@ -1,3 +1,5 @@
package colormap
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.shadeStyle
@@ -7,6 +9,10 @@ import org.openrndr.extra.shaderphrases.preprocess
import org.openrndr.math.Vector2
fun main() = application {
configure {
width = 720
height = 360
}
program {
ColormapPhraseBook.register()
val backgroundStyle = shadeStyle {

View File

@@ -1,10 +1,14 @@
// Show color histogram of an image
package histogram// Show color histogram of an image
import org.openrndr.application
import org.openrndr.draw.loadImage
import org.openrndr.extra.color.statistics.calculateHistogramRGB
fun main() = application {
configure {
width = 720
height = 540
}
program {
val useColors = 32
val image = loadImage("demo-data/images/image-001.png")
@@ -29,7 +33,7 @@ fun main() = application {
"% of the image colors.")
extend {
drawer.image(image)
drawer.image(image, 0.0, 0.0, width * 1.0, height * 1.0)
drawer.stroke = null
var x = 0.0
topColorsSortedByLuminosity.forEachIndexed { i, (color, freq) ->

View File

@@ -1,4 +1,4 @@
// Show color histogram using non-uniform weighting
package histogram// Show color histogram using non-uniform weighting
import org.openrndr.application
import org.openrndr.draw.loadImage
@@ -6,6 +6,10 @@ import org.openrndr.extra.color.statistics.calculateHistogramRGB
import kotlin.math.pow
fun main() = application {
configure {
width = 720
height = 540
}
program {
val image = loadImage("demo-data/images/image-001.png")
// -- here we use non-uniform weighting, such that bright colors are prioritized
@@ -16,7 +20,7 @@ fun main() = application {
// .subList(0, 32).sortedBy { it.first.toHSLa().h } // sort by hue
extend {
drawer.image(image)
drawer.image(image, 0.0, 0.0, width * 1.0, height * 1.0)
for (i in 0 until 32) {
drawer.fill = colors[i].first
drawer.stroke = null

View File

@@ -1,15 +1,18 @@
// Create a simple rectangle composition based on colors sampled from image
package histogram// Create a simple rectangle composition based on colors sampled from image
import org.openrndr.application
import org.openrndr.draw.loadImage
import org.openrndr.extra.color.statistics.calculateHistogramRGB
fun main() = application {
configure {
width = 720
height = 540
}
program {
val image = loadImage("demo-data/images/image-001.png")
val histogram = calculateHistogramRGB(image)
extend {
drawer.image(image)
for (j in 0 until height step 32) {
for (i in 0 until width step 32) {
drawer.stroke = null