[orx-noise] Tidy up demos

Produce 720px wide images.
Use main() = application { for reduced indentation
This commit is contained in:
Abe Pazos
2025-01-24 21:47:44 +01:00
parent a1b4070b51
commit c85144c6fe
23 changed files with 347 additions and 347 deletions

View File

@@ -185,21 +185,8 @@ val v7 = billow(seed, x, y, z, ::perlinLinear, octaves, lacunarity, gain)
val v8 = billow(seed, x, y, z, ::perlinLinear, octaves, lacunarity, gain) val v8 = billow(seed, x, y, z, ::perlinLinear, octaves, lacunarity, gain)
``` ```
<!-- __demos__ >
# Demos
[DemoGradientPerturb2DKt](src/demo/kotlin/DemoGradientPerturb2DKt.kt
![DemoGradientPerturb2DKt](https://github.com/openrndr/orx/blob/media/orx-noise/images/DemoGradientPerturb2DKt.png
[DemoGradientPerturb3DKt](src/demo/kotlin/DemoGradientPerturb3DKt.kt
![DemoGradientPerturb3DKt](https://github.com/openrndr/orx/blob/media/orx-noise/images/DemoGradientPerturb3DKt.png
[DemoPoissonDiskSamplingKt](src/demo/kotlin/DemoPoissonDiskSamplingKt.kt
![DemoPoissonDiskSamplingKt](https://github.com/openrndr/orx/blob/media/orx-noise/images/DemoPoissonDiskSamplingKt.png
<!-- __demos__ --> <!-- __demos__ -->
## Demos ## Demos
### DemoCircleHash01
[source code](src/jvmDemo/kotlin/DemoCircleHash01.kt)
![DemoCircleHash01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoCircleHash01Kt.png)
### DemoCubicNoise2D01 ### DemoCubicNoise2D01
[source code](src/jvmDemo/kotlin/DemoCubicNoise2D01.kt) [source code](src/jvmDemo/kotlin/DemoCubicNoise2D01.kt)
@@ -220,21 +207,6 @@ val v8 = billow(seed, x, y, z, ::perlinLinear, octaves, lacunarity, gain)
![DemoGradientPerturb3DKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoGradientPerturb3DKt.png) ![DemoGradientPerturb3DKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoGradientPerturb3DKt.png)
### DemoNoisesGLSLGui
[source code](src/jvmDemo/kotlin/DemoNoisesGLSLGui.kt)
![DemoNoisesGLSLGuiKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoNoisesGLSLGuiKt.png)
### DemoNoisesGLSL
[source code](src/jvmDemo/kotlin/DemoNoisesGLSL.kt)
![DemoNoisesGLSLKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoNoisesGLSLKt.png)
### DemoRectangleHash01
[source code](src/jvmDemo/kotlin/DemoRectangleHash01.kt)
![DemoRectangleHash01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoRectangleHash01Kt.png)
### DemoScatter01 ### DemoScatter01
[source code](src/jvmDemo/kotlin/DemoScatter01.kt) [source code](src/jvmDemo/kotlin/DemoScatter01.kt)
@@ -245,26 +217,31 @@ val v8 = billow(seed, x, y, z, ::perlinLinear, octaves, lacunarity, gain)
![DemoSimplex01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoSimplex01Kt.png) ![DemoSimplex01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoSimplex01Kt.png)
### DemoSimplexGLSL
[source code](src/jvmDemo/kotlin/DemoSimplexGLSL.kt)
![DemoSimplexGLSLKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoSimplexGLSLKt.png)
### DemoTriangleNoise01 ### DemoTriangleNoise01
[source code](src/jvmDemo/kotlin/DemoTriangleNoise01.kt) [source code](src/jvmDemo/kotlin/DemoTriangleNoise01.kt)
![DemoTriangleNoise01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoTriangleNoise01Kt.png) ![DemoTriangleNoise01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoTriangleNoise01Kt.png)
### DemoUHash01
[source code](src/jvmDemo/kotlin/DemoUHash01.kt)
![DemoUHash01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoUHash01Kt.png)
### DemoValueNoise2D01 ### DemoValueNoise2D01
[source code](src/jvmDemo/kotlin/DemoValueNoise2D01.kt) [source code](src/jvmDemo/kotlin/DemoValueNoise2D01.kt)
![DemoValueNoise2D01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoValueNoise2D01Kt.png) ![DemoValueNoise2D01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoValueNoise2D01Kt.png)
### glsl/DemoNoisesGLSLGui
[source code](src/jvmDemo/kotlin/glsl/DemoNoisesGLSLGui.kt)
![glsl-DemoNoisesGLSLGuiKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/glsl-DemoNoisesGLSLGuiKt.png)
### glsl/DemoNoisesGLSL
[source code](src/jvmDemo/kotlin/glsl/DemoNoisesGLSL.kt)
![glsl-DemoNoisesGLSLKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/glsl-DemoNoisesGLSLKt.png)
### glsl/DemoSimplexGLSL
[source code](src/jvmDemo/kotlin/glsl/DemoSimplexGLSL.kt)
![glsl-DemoSimplexGLSLKt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/glsl-DemoSimplexGLSLKt.png)
### hammersley/DemoHammersley2D01 ### hammersley/DemoHammersley2D01
[source code](src/jvmDemo/kotlin/hammersley/DemoHammersley2D01.kt) [source code](src/jvmDemo/kotlin/hammersley/DemoHammersley2D01.kt)
@@ -280,6 +257,21 @@ val v8 = billow(seed, x, y, z, ::perlinLinear, octaves, lacunarity, gain)
![hammersley-DemoHammersley4D01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/hammersley-DemoHammersley4D01Kt.png) ![hammersley-DemoHammersley4D01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/hammersley-DemoHammersley4D01Kt.png)
### hash/DemoCircleHash01
[source code](src/jvmDemo/kotlin/hash/DemoCircleHash01.kt)
![hash-DemoCircleHash01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/hash-DemoCircleHash01Kt.png)
### hash/DemoRectangleHash01
[source code](src/jvmDemo/kotlin/hash/DemoRectangleHash01.kt)
![hash-DemoRectangleHash01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/hash-DemoRectangleHash01Kt.png)
### hash/DemoUHash01
[source code](src/jvmDemo/kotlin/hash/DemoUHash01.kt)
![hash-DemoUHash01Kt](https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/hash-DemoUHash01Kt.png)
### phrases/DemoUHashPhrase01 ### phrases/DemoUHashPhrase01
[source code](src/jvmDemo/kotlin/phrases/DemoUHashPhrase01.kt) [source code](src/jvmDemo/kotlin/phrases/DemoUHashPhrase01.kt)

View File

@@ -1,33 +0,0 @@
import org.openrndr.application
import org.openrndr.extra.noise.shapes.hash
import org.openrndr.extra.noise.shapes.uniform
import org.openrndr.shape.Circle
import kotlin.random.Random
fun main() {
application {
configure {
width = 720
height = 720
}
program {
extend {
val b = drawer.bounds
val b0 = b.sub(0.0, 0.0, 0.5, 1.0).offsetEdges(-10.0)
val b1 = b.sub(0.5, 0.0, 1.0, 1.0).offsetEdges(-10.0)
val c0 = Circle(b0.center, b0.width/2.0)
val c1 = Circle(b1.center, b1.width/2.0)
val r = Random(0)
for (i in 0 until 2000) {
drawer.circle(c0.uniform(r), 2.0)
drawer.circle(c1.hash(909, i),2.0)
}
}
}
}
}

View File

@@ -1,21 +1,23 @@
import org.openrndr.application import org.openrndr.application
import org.openrndr.color.ColorRGBa import org.openrndr.color.ColorRGBa
import org.openrndr.extra.noise.* import org.openrndr.extra.noise.cubicHermite3D
fun main() { fun main() = application {
application { configure {
program { width = 720
extend { height = 360
drawer.points { }
for (y in 0 until height) { program {
for (x in 0 until width) { extend {
val c = cubicHermite3D(100, (x + y) * 0.04, (x - y) * 0.04, seconds * 1.0) * 0.5 + 0.5 drawer.points {
fill = ColorRGBa(c, c, c, 1.0) for (y in 0 until height) {
point(x.toDouble(), y.toDouble()) for (x in 0 until width) {
} val c = cubicHermite3D(100, (x + y) * 0.04, (x - y) * 0.04, seconds * 1.0) * 0.5 + 0.5
fill = ColorRGBa(c, c, c, 1.0)
point(x.toDouble(), y.toDouble())
} }
} }
} }
} }
} }
} }

View File

@@ -6,22 +6,25 @@ import org.openrndr.extra.noise.simplex
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import kotlin.math.absoluteValue import kotlin.math.absoluteValue
fun main() { fun main() = application {
application { configure {
program { width = 720
val cb = colorBuffer(width, height) height = 360
val shad = cb.shadow }
extend { program {
for (y in 0 until height) { val cb = colorBuffer(width, height)
for (x in 0 until width) { val shad = cb.shadow
val p = gradientPerturbFractal(300, frequency = 0.8, position = Vector2(seconds + x/320.0,y/240.0)) extend {
val d = simplex(300, p.x, p.y+seconds, seconds).absoluteValue for (y in 0 until height) {
shad[x, y] = ColorRGBa(d, d, d, 1.0) for (x in 0 until width) {
} val p =
gradientPerturbFractal(300, frequency = 0.8, position = Vector2(seconds + x / 320.0, y / 240.0))
val d = simplex(300, p.x, p.y + seconds, seconds).absoluteValue
shad[x, y] = ColorRGBa(d, d, d, 1.0)
} }
shad.upload()
drawer.image(cb)
} }
shad.upload()
drawer.image(cb)
} }
} }
} }

View File

@@ -6,22 +6,25 @@ import org.openrndr.extra.noise.simplex
import org.openrndr.math.Vector3 import org.openrndr.math.Vector3
import kotlin.math.absoluteValue import kotlin.math.absoluteValue
fun main() { fun main() = application {
application { configure {
program { width = 720
val cb = colorBuffer(width, height) height = 360
val shad = cb.shadow }
extend { program {
for (y in 0 until height) { val cb = colorBuffer(width, height)
for (x in 0 until width) { val shad = cb.shadow
val p = gradientPerturbFractal(300, frequency = 0.8, position = Vector3(x/320.0,y/240.0, seconds)) extend {
val d = simplex(300, p.x, p.y, p.z).absoluteValue for (y in 0 until height) {
shad[x, y] = ColorRGBa(d, d, d, 1.0) for (x in 0 until width) {
} val p =
gradientPerturbFractal(300, frequency = 0.8, position = Vector3(x / 320.0, y / 240.0, seconds))
val d = simplex(300, p.x, p.y, p.z).absoluteValue
shad[x, y] = ColorRGBa(d, d, d, 1.0)
} }
shad.upload()
drawer.image(cb)
} }
shad.upload()
drawer.image(cb)
} }
} }
} }

View File

@@ -1,29 +0,0 @@
import org.openrndr.application
import org.openrndr.extra.noise.shapes.hash
import org.openrndr.extra.noise.shapes.uniform
import kotlin.random.Random
fun main() {
application {
configure {
width = 720
height = 720
}
program {
extend {
val b = drawer.bounds
val b0 = b.sub(0.0, 0.0, 0.5, 1.0).offsetEdges(-10.0)
val b1 = b.sub(0.5, 0.0, 1.0, 1.0).offsetEdges(-10.0)
val r = Random(0)
for (i in 0 until 20000) {
drawer.circle(b0.uniform(r), 2.0)
drawer.circle(b1.hash(909, i),2.0)
}
}
}
}
}

View File

@@ -6,23 +6,25 @@ import org.openrndr.shape.Ellipse
import kotlin.math.cos import kotlin.math.cos
import kotlin.random.Random import kotlin.random.Random
fun main() { fun main() = application {
application { configure {
program { width = 720
extend { height = 540
val shape = Ellipse(Vector2(width/2.0, height/2.0), 200.0, 150.0 + cos(seconds)*125.0).shape }
val points = shape.scatter(20.0, random = Random(0)) program {
drawer.clear(ColorRGBa.BLACK) extend {
drawer.stroke = null val shape = Ellipse(Vector2(width / 2.0, height / 2.0), 200.0, 150.0 + cos(seconds) * 125.0).shape
drawer.fill = ColorRGBa.PINK val points = shape.scatter(20.0, random = Random(0))
drawer.circles(points, 4.0) drawer.clear(ColorRGBa.BLACK)
drawer.stroke = null
drawer.fill = ColorRGBa.PINK
drawer.circles(points, 4.0)
if (seconds.mod(2.0) < 1.0) { if (seconds.mod(2.0) < 1.0) {
drawer.stroke = ColorRGBa.PINK drawer.stroke = ColorRGBa.PINK
drawer.fill = null drawer.fill = null
drawer.shape(shape) drawer.shape(shape)
}
} }
} }
} }
} }

View File

@@ -7,26 +7,24 @@ import org.openrndr.shape.Triangle
* Demonstrate the generation of uniformly distributed points inside a list of triangles * Demonstrate the generation of uniformly distributed points inside a list of triangles
* @see <img src="https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoTriangleNoise01Kt.png"> * @see <img src="https://raw.githubusercontent.com/openrndr/orx/media/orx-noise/images/DemoTriangleNoise01Kt.png">
*/ */
fun main() { fun main() = application {
application { configure {
configure { width = 720
width = 720 height = 720
height = 720 }
} program {
program { val r = drawer.bounds.offsetEdges(-100.0)
val r = drawer.bounds.offsetEdges(-100.0) val triangle = Triangle(r.position(0.5, 0.0), r.position(0.0, 1.0), r.position(1.0, 1.0))
val triangle = Triangle(r.position(0.5, 0.0), r.position(0.0, 1.0), r.position(1.0, 1.0)) //val pts = listOf(triangle).uniform(1000, Random(0))
//val pts = listOf(triangle).uniform(1000, Random(0))
extend { extend {
val pts = listOf(triangle).hash(1000, 0, (seconds*500.0).toInt()) val pts = listOf(triangle).hash(1000, 0, (seconds * 500.0).toInt())
drawer.clear(ColorRGBa.PINK) drawer.clear(ColorRGBa.PINK)
drawer.stroke = null drawer.stroke = null
drawer.contour(triangle.contour) drawer.contour(triangle.contour)
drawer.fill = ColorRGBa.BLACK drawer.fill = ColorRGBa.BLACK
drawer.circles(pts, 5.0) drawer.circles(pts, 5.0)
}
} }
} }
} }

View File

@@ -1,26 +0,0 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.drawImage
import org.openrndr.extra.noise.*
fun main() {
application {
program {
extend {
drawer.points {
for (y in 0 until height) {
for (x in 0 until width) {
val c = fhash3D(100, x + (seconds*60.0).toInt(), y, (0).toInt())
//val u = uhash11(x.toUInt()).toDouble() / UInt.MAX_VALUE.toDouble()
fill = ColorRGBa(c, c, c, 1.0)
point(x.toDouble(), y.toDouble())
}
}
}
}
}
}
}

View File

@@ -1,21 +1,23 @@
import org.openrndr.application import org.openrndr.application
import org.openrndr.color.ColorRGBa import org.openrndr.color.ColorRGBa
import org.openrndr.extra.noise.* import org.openrndr.extra.noise.valueQuintic3D
fun main() { fun main() = application {
application { configure {
program { width = 720
extend { height = 360
drawer.points { }
for (y in 0 until height) { program {
for (x in 0 until width) { extend {
val c = valueQuintic3D(100, (x + y) * 0.04, (x - y) * 0.04, seconds * 0.1) * 0.5 + 0.5 drawer.points {
fill = ColorRGBa(c, c, c, 1.0) for (y in 0 until height) {
point(x.toDouble(), y.toDouble()) for (x in 0 until width) {
} val c = valueQuintic3D(100, (x + y) * 0.04, (x - y) * 0.04, seconds * 0.1) * 0.5 + 0.5
fill = ColorRGBa(c, c, c, 1.0)
point(x.toDouble(), y.toDouble())
} }
} }
} }
} }
} }
} }

View File

@@ -1,3 +1,5 @@
package glsl
import org.openrndr.application import org.openrndr.application
import org.openrndr.draw.colorBuffer import org.openrndr.draw.colorBuffer
import org.openrndr.extra.noise.filters.* import org.openrndr.extra.noise.filters.*
@@ -14,6 +16,10 @@ import kotlin.math.sin
* The noise color can be set using a `color` or a `gain` property. * The noise color can be set using a `color` or a `gain` property.
*/ */
fun main() = application { fun main() = application {
configure {
width = 720
height = 360
}
program { program {
val noises = listOf( val noises = listOf(
HashNoise(), SpeckleNoise(), CellNoise(), HashNoise(), SpeckleNoise(), CellNoise(),

View File

@@ -1,3 +1,5 @@
package glsl
import org.openrndr.application import org.openrndr.application
import org.openrndr.draw.colorBuffer import org.openrndr.draw.colorBuffer
import org.openrndr.extra.gui.GUI import org.openrndr.extra.gui.GUI
@@ -9,8 +11,10 @@ import org.openrndr.extra.noise.filters.*
*/ */
fun main() = application { fun main() = application {
configure { configure {
width = 200 * 6 + 200 configure {
height = 500 width = 720
height = 360
}
} }
program { program {
val noises = listOf( val noises = listOf(
@@ -18,7 +22,7 @@ fun main() = application {
ValueNoise(), SimplexNoise3D(), WorleyNoise() ValueNoise(), SimplexNoise3D(), WorleyNoise()
) )
val img = colorBuffer(200, 460) val img = colorBuffer((width - 200) / noises.size, 460)
val gui = GUI() val gui = GUI()
noises.forEach { gui.add(it) } noises.forEach { gui.add(it) }
@@ -27,7 +31,7 @@ fun main() = application {
extend { extend {
noises.forEachIndexed { i, noise -> noises.forEachIndexed { i, noise ->
noise.apply(emptyArray(), img) noise.apply(emptyArray(), img)
drawer.image(img, 200.0 + i * 200.0, 20.0) drawer.image(img, 200.0 + i * img.width, 20.0)
} }
} }
} }

View File

@@ -1,8 +1,10 @@
package glsl
import org.openrndr.application import org.openrndr.application
import org.openrndr.color.rgb import org.openrndr.color.rgb
import org.openrndr.draw.colorBuffer import org.openrndr.draw.colorBuffer
import org.openrndr.extra.noise.Random import org.openrndr.extra.noise.filters.SimplexNoise3D
import org.openrndr.extra.noise.filters.* import org.openrndr.extra.noise.uniform
import org.openrndr.math.Vector3 import org.openrndr.math.Vector3
import org.openrndr.math.Vector4 import org.openrndr.math.Vector4
import kotlin.math.sin import kotlin.math.sin
@@ -11,10 +13,10 @@ import kotlin.math.sin
* A sine oscillator with randomized parameters * A sine oscillator with randomized parameters
*/ */
class SinOsc { class SinOsc {
private val freq = Random.double(0.1, 2.0) private val freq = Double.uniform(0.1, 2.0)
private val phase = Random.double(0.0, 6.28) private val phase = Double.uniform(0.0, 6.28)
private val add = Random.double(0.0, 1.0) private val add = Double.uniform(0.0, 1.0)
private val mul = Random.double(0.0, 1.0 - add) private val mul = Double.uniform(0.0, 1.0 - add)
operator fun invoke() = sin(System.currentTimeMillis() * 0.0001 * freq + phase) * mul + add operator fun invoke() = sin(System.currentTimeMillis() * 0.0001 * freq + phase) * mul + add
} }
@@ -25,6 +27,10 @@ class SinOsc {
* randomized sine oscillators. * randomized sine oscillators.
*/ */
fun main() = application { fun main() = application {
configure {
width = 720
height = 540
}
program { program {
val noise = SimplexNoise3D() val noise = SimplexNoise3D()
val img = colorBuffer(width, height) val img = colorBuffer(width, height)

View File

@@ -10,20 +10,18 @@ import org.openrndr.extra.noise.hammersley.hammersley2D
* 400 2D Hammersley points mapped within the bounds of the application's resolution. * 400 2D Hammersley points mapped within the bounds of the application's resolution.
* These points are visualized by rendering circles at their respective positions. * These points are visualized by rendering circles at their respective positions.
*/ */
fun main() { fun main() = application {
application { configure {
configure { width = 720
width = 720 height = 720
height = 720 }
}
program { program {
extend { extend {
val points = (0 until 400).map { val points = (0 until 400).map {
hammersley2D(it, 400) * 720.0 hammersley2D(it, 400) * 720.0
}
drawer.circles(points, 5.0)
} }
drawer.circles(points, 5.0)
} }
} }
} }

View File

@@ -20,27 +20,25 @@ import org.openrndr.math.Vector3
* to navigate the scene. The visualization relies on the draw loop for continuous * to navigate the scene. The visualization relies on the draw loop for continuous
* rendering of the points. * rendering of the points.
*/ */
fun main() { fun main() = application {
application { configure {
configure { width = 720
width = 720 height = 720
height = 720 }
}
program { program {
val sphere = sphereMesh(radius = 0.1) val sphere = sphereMesh(radius = 0.1)
extend(Orbital()) extend(Orbital())
extend { extend {
val points = (0 until 1400).map { val points = (0 until 1400).map {
(hammersley3D(it, 1400) - Vector3(0.5)) * 10.0 (hammersley3D(it, 1400) - Vector3(0.5)) * 10.0
} }
for (point in points) { for (point in points) {
drawer.isolated { drawer.isolated {
drawer.translate(point) drawer.translate(point)
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES) drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
}
} }
} }
} }
} }
} }

View File

@@ -7,10 +7,7 @@ import org.openrndr.draw.isolated
import org.openrndr.extra.camera.Orbital import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.meshgenerators.sphereMesh import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.extra.noise.hammersley.hammersley4D import org.openrndr.extra.noise.hammersley.hammersley4D
import org.openrndr.extra.noise.rsequence.rSeq4D
import org.openrndr.math.Vector4 import org.openrndr.math.Vector4
import kotlin.math.abs
import kotlin.math.min
/** /**
* Demo that visualizes a 4D Hammersley point set in a 3D space, with colors determined by the 4th dimension. * Demo that visualizes a 4D Hammersley point set in a 3D space, with colors determined by the 4th dimension.
@@ -25,28 +22,26 @@ import kotlin.math.min
* of the scene. Rendering occurs within the draw loop, providing continuous visualization * of the scene. Rendering occurs within the draw loop, providing continuous visualization
* of the point distribution. * of the point distribution.
*/ */
fun main() { fun main() = application {
application { configure {
configure { width = 720
width = 720 height = 720
height = 720 }
}
program { program {
val sphere = sphereMesh(radius = 0.1) val sphere = sphereMesh(radius = 0.1)
extend(Orbital()) extend(Orbital())
extend { extend {
val points = (0 until 10000).map { val points = (0 until 10000).map {
(hammersley4D(it, 10000) - Vector4(0.5, 0.5, 0.5, 0.0)) * Vector4(10.0, 10.0, 10.0, 1.0) (hammersley4D(it, 10000) - Vector4(0.5, 0.5, 0.5, 0.0)) * Vector4(10.0, 10.0, 10.0, 1.0)
} }
for (point in points) { for (point in points) {
drawer.isolated { drawer.isolated {
drawer.translate(point.xyz) drawer.translate(point.xyz)
drawer.fill = ColorRGBa.RED.toHSVa().shiftHue(point.w * 360.0).toRGBa() drawer.fill = ColorRGBa.RED.toHSVa().shiftHue(point.w * 360.0).toRGBa()
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES) drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
}
} }
} }
} }
} }
} }

View File

@@ -0,0 +1,30 @@
package hash
import org.openrndr.application
import org.openrndr.extra.noise.shapes.hash
import org.openrndr.extra.noise.shapes.uniform
import org.openrndr.shape.Circle
import kotlin.random.Random
fun main() = application {
configure {
width = 720
height = 360
}
program {
extend {
val b = drawer.bounds
val b0 = b.sub(0.0, 0.0, 0.5, 1.0).offsetEdges(-10.0)
val b1 = b.sub(0.5, 0.0, 1.0, 1.0).offsetEdges(-10.0)
val c0 = Circle(b0.center, b0.width / 2.0)
val c1 = Circle(b1.center, b1.width / 2.0)
val r = Random(0)
for (i in 0 until 2000) {
drawer.circle(c0.uniform(r), 2.0)
drawer.circle(c1.hash(909, i), 2.0)
}
}
}
}

View File

@@ -0,0 +1,27 @@
package hash
import org.openrndr.application
import org.openrndr.extra.noise.shapes.hash
import org.openrndr.extra.noise.shapes.uniform
import kotlin.random.Random
fun main() = application {
configure {
width = 720
height = 540
}
program {
extend {
val b = drawer.bounds
val b0 = b.sub(0.0, 0.0, 0.5, 1.0).offsetEdges(-10.0)
val b1 = b.sub(0.5, 0.0, 1.0, 1.0).offsetEdges(-10.0)
val r = Random(0)
for (i in 0 until 20000) {
drawer.circle(b0.uniform(r), 2.0)
drawer.circle(b1.hash(909, i), 2.0)
}
}
}
}

View File

@@ -0,0 +1,26 @@
package hash
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.noise.fhash3D
fun main() = application {
configure {
width = 720
height = 360
}
program {
extend {
drawer.points {
for (y in 0 until height) {
for (x in 0 until width) {
val c = fhash3D(100, x + (seconds * 60.0).toInt(), y, (0).toInt())
//val u = uhash11(x.toUInt()).toDouble() / UInt.MAX_VALUE.toDouble()
fill = ColorRGBa(c, c, c, 1.0)
point(x.toDouble(), y.toDouble())
}
}
}
}
}
}

View File

@@ -2,27 +2,29 @@ package phrases
import org.openrndr.application import org.openrndr.application
import org.openrndr.draw.shadeStyle import org.openrndr.draw.shadeStyle
import org.openrndr.extra.noise.phrases.* import org.openrndr.extra.noise.phrases.fhash13
/** /**
* Demonstrate uniform hashing function phrase in a shadestyle * Demonstrate uniform hashing function phrase in a shadestyle
*/ */
fun main() { fun main() = application {
application { configure {
program { width = 720
extend { height = 360
/** A custom shadestyle */ }
val ss = shadeStyle { program {
fragmentPreamble = """$fhash13""" extend {
fragmentTransform = """ /** A custom shadestyle */
val ss = shadeStyle {
fragmentPreamble = """$fhash13"""
fragmentTransform = """
float cf = fhash13(vec3(c_screenPosition, p_time)); float cf = fhash13(vec3(c_screenPosition, p_time));
x_fill = vec4(cf, cf, cf, 1.0); x_fill = vec4(cf, cf, cf, 1.0);
""".trimIndent() """.trimIndent()
parameter("time", seconds) parameter("time", seconds)
}
drawer.shadeStyle = ss
drawer.circle(drawer.bounds.center, 100.0)
} }
drawer.shadeStyle = ss
drawer.circle(drawer.bounds.center, 100.0)
} }
} }
} }

View File

@@ -8,20 +8,18 @@ import org.openrndr.extra.noise.rsequence.rSeq2D
* demonstrating 2D quasirandomly distributed points. The points are generated * demonstrating 2D quasirandomly distributed points. The points are generated
* using the R2 sequence and drawn as circles with a radius of 5.0. * using the R2 sequence and drawn as circles with a radius of 5.0.
*/ */
fun main() { fun main() = application {
application { configure {
configure { width = 720
width = 720 height = 720
height = 720 }
}
program { program {
extend { extend {
val points = (0 until 4000).map { val points = (0 until 4000).map {
rSeq2D(it) * 720.0 rSeq2D(it) * 720.0
}
drawer.circles(points, 5.0)
} }
drawer.circles(points, 5.0)
} }
} }
} }

View File

@@ -19,27 +19,25 @@ import org.openrndr.math.Vector3
* - Generation of quasirandom points in 3D space using the `rSeq3D` function. * - Generation of quasirandom points in 3D space using the `rSeq3D` function.
* - Transformation and rendering of each point as a sphere using vertex buffers. * - Transformation and rendering of each point as a sphere using vertex buffers.
*/ */
fun main() { fun main() = application {
application { configure {
configure { width = 720
width = 720 height = 720
height = 720 }
}
program { program {
val sphere = sphereMesh(radius = 0.1) val sphere = sphereMesh(radius = 0.1)
extend(Orbital()) extend(Orbital())
extend { extend {
val points = (0 until 1400).map { val points = (0 until 1400).map {
(rSeq3D(it) - Vector3(0.5)) * 10.0 (rSeq3D(it) - Vector3(0.5)) * 10.0
} }
for (point in points) { for (point in points) {
drawer.isolated { drawer.isolated {
drawer.translate(point) drawer.translate(point)
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES) drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
}
} }
} }
} }
} }
} }

View File

@@ -27,28 +27,26 @@ import kotlin.math.min
* of the point and its color calculated by shifting the hue of a base color using * of the point and its color calculated by shifting the hue of a base color using
* the w-coordinate value. * the w-coordinate value.
*/ */
fun main() { fun main() = application {
application { configure {
configure { width = 720
width = 720 height = 720
height = 720 }
}
program { program {
val sphere = sphereMesh(radius = 0.1) val sphere = sphereMesh(radius = 0.1)
val points = (0 until 10000).map { val points = (0 until 10000).map {
(rSeq4D(it) - Vector4(0.5, 0.5, 0.5, 0.0)) * Vector4(10.0, 10.0, 10.0, 1.0) (rSeq4D(it) - Vector4(0.5, 0.5, 0.5, 0.0)) * Vector4(10.0, 10.0, 10.0, 1.0)
} }
extend(Orbital()) extend(Orbital())
extend { extend {
for (point in points) { for (point in points) {
drawer.isolated { drawer.isolated {
drawer.translate(point.xyz) drawer.translate(point.xyz)
drawer.fill = ColorRGBa.RED.toHSVa().shiftHue(point.w * 360.0).toRGBa() drawer.fill = ColorRGBa.RED.toHSVa().shiftHue(point.w * 360.0).toRGBa()
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES) drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
}
} }
} }
} }
} }
} }