[orx-noise] Tidy up demos
Produce 720px wide images.
Use main() = application { for reduced indentation
This commit is contained in:
@@ -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)
|
||||
```
|
||||
|
||||
<!-- __demos__ >
|
||||
# Demos
|
||||
[DemoGradientPerturb2DKt](src/demo/kotlin/DemoGradientPerturb2DKt.kt
|
||||

|
||||
|
||||

|
||||
|
||||
### DemoCubicNoise2D01
|
||||
[source code](src/jvmDemo/kotlin/DemoCubicNoise2D01.kt)
|
||||
|
||||
@@ -220,21 +207,6 @@ val v8 = billow(seed, x, y, z, ::perlinLinear, octaves, lacunarity, gain)
|
||||
|
||||

|
||||
|
||||
### DemoNoisesGLSLGui
|
||||
[source code](src/jvmDemo/kotlin/DemoNoisesGLSLGui.kt)
|
||||
|
||||

|
||||
|
||||
### DemoNoisesGLSL
|
||||
[source code](src/jvmDemo/kotlin/DemoNoisesGLSL.kt)
|
||||
|
||||

|
||||
|
||||
### DemoRectangleHash01
|
||||
[source code](src/jvmDemo/kotlin/DemoRectangleHash01.kt)
|
||||
|
||||

|
||||
|
||||
### DemoScatter01
|
||||
[source code](src/jvmDemo/kotlin/DemoScatter01.kt)
|
||||
|
||||
@@ -245,26 +217,31 @@ val v8 = billow(seed, x, y, z, ::perlinLinear, octaves, lacunarity, gain)
|
||||
|
||||

|
||||
|
||||
### DemoSimplexGLSL
|
||||
[source code](src/jvmDemo/kotlin/DemoSimplexGLSL.kt)
|
||||
|
||||

|
||||
|
||||
### DemoTriangleNoise01
|
||||
[source code](src/jvmDemo/kotlin/DemoTriangleNoise01.kt)
|
||||
|
||||

|
||||
|
||||
### DemoUHash01
|
||||
[source code](src/jvmDemo/kotlin/DemoUHash01.kt)
|
||||
|
||||

|
||||
|
||||
### DemoValueNoise2D01
|
||||
[source code](src/jvmDemo/kotlin/DemoValueNoise2D01.kt)
|
||||
|
||||

|
||||
|
||||
### glsl/DemoNoisesGLSLGui
|
||||
[source code](src/jvmDemo/kotlin/glsl/DemoNoisesGLSLGui.kt)
|
||||
|
||||

|
||||
|
||||
### glsl/DemoNoisesGLSL
|
||||
[source code](src/jvmDemo/kotlin/glsl/DemoNoisesGLSL.kt)
|
||||
|
||||

|
||||
|
||||
### glsl/DemoSimplexGLSL
|
||||
[source code](src/jvmDemo/kotlin/glsl/DemoSimplexGLSL.kt)
|
||||
|
||||

|
||||
|
||||
### hammersley/DemoHammersley2D01
|
||||
[source code](src/jvmDemo/kotlin/hammersley/DemoHammersley2D01.kt)
|
||||
|
||||
@@ -280,6 +257,21 @@ val v8 = billow(seed, x, y, z, ::perlinLinear, octaves, lacunarity, gain)
|
||||
|
||||

|
||||
|
||||
### hash/DemoCircleHash01
|
||||
[source code](src/jvmDemo/kotlin/hash/DemoCircleHash01.kt)
|
||||
|
||||

|
||||
|
||||
### hash/DemoRectangleHash01
|
||||
[source code](src/jvmDemo/kotlin/hash/DemoRectangleHash01.kt)
|
||||
|
||||

|
||||
|
||||
### hash/DemoUHash01
|
||||
[source code](src/jvmDemo/kotlin/hash/DemoUHash01.kt)
|
||||
|
||||

|
||||
|
||||
### phrases/DemoUHashPhrase01
|
||||
[source code](src/jvmDemo/kotlin/phrases/DemoUHashPhrase01.kt)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,23 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.noise.*
|
||||
import org.openrndr.extra.noise.cubicHermite3D
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
extend {
|
||||
drawer.points {
|
||||
for (y in 0 until height) {
|
||||
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())
|
||||
}
|
||||
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 = 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())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,22 +6,25 @@ import org.openrndr.extra.noise.simplex
|
||||
import org.openrndr.math.Vector2
|
||||
import kotlin.math.absoluteValue
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
val cb = colorBuffer(width, height)
|
||||
val shad = cb.shadow
|
||||
extend {
|
||||
for (y in 0 until height) {
|
||||
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)
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 360
|
||||
}
|
||||
program {
|
||||
val cb = colorBuffer(width, height)
|
||||
val shad = cb.shadow
|
||||
extend {
|
||||
for (y in 0 until height) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,22 +6,25 @@ import org.openrndr.extra.noise.simplex
|
||||
import org.openrndr.math.Vector3
|
||||
import kotlin.math.absoluteValue
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
val cb = colorBuffer(width, height)
|
||||
val shad = cb.shadow
|
||||
extend {
|
||||
for (y in 0 until height) {
|
||||
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)
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 360
|
||||
}
|
||||
program {
|
||||
val cb = colorBuffer(width, height)
|
||||
val shad = cb.shadow
|
||||
extend {
|
||||
for (y in 0 until height) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,23 +6,25 @@ import org.openrndr.shape.Ellipse
|
||||
import kotlin.math.cos
|
||||
import kotlin.random.Random
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
extend {
|
||||
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))
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = null
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
drawer.circles(points, 4.0)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 540
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
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))
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.stroke = null
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
drawer.circles(points, 4.0)
|
||||
|
||||
if (seconds.mod(2.0) < 1.0) {
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.fill = null
|
||||
drawer.shape(shape)
|
||||
}
|
||||
if (seconds.mod(2.0) < 1.0) {
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.fill = null
|
||||
drawer.shape(shape)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,26 +7,24 @@ import org.openrndr.shape.Triangle
|
||||
* 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">
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
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 pts = listOf(triangle).uniform(1000, Random(0))
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
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 pts = listOf(triangle).uniform(1000, Random(0))
|
||||
|
||||
extend {
|
||||
val pts = listOf(triangle).hash(1000, 0, (seconds*500.0).toInt())
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.stroke = null
|
||||
drawer.contour(triangle.contour)
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
extend {
|
||||
val pts = listOf(triangle).hash(1000, 0, (seconds * 500.0).toInt())
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.stroke = null
|
||||
drawer.contour(triangle.contour)
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
|
||||
drawer.circles(pts, 5.0)
|
||||
}
|
||||
drawer.circles(pts, 5.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,23 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.noise.*
|
||||
import org.openrndr.extra.noise.valueQuintic3D
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
extend {
|
||||
drawer.points {
|
||||
for (y in 0 until height) {
|
||||
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())
|
||||
}
|
||||
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 = 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())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package glsl
|
||||
|
||||
import org.openrndr.application
|
||||
import org.openrndr.draw.colorBuffer
|
||||
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.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 360
|
||||
}
|
||||
program {
|
||||
val noises = listOf(
|
||||
HashNoise(), SpeckleNoise(), CellNoise(),
|
||||
@@ -1,3 +1,5 @@
|
||||
package glsl
|
||||
|
||||
import org.openrndr.application
|
||||
import org.openrndr.draw.colorBuffer
|
||||
import org.openrndr.extra.gui.GUI
|
||||
@@ -9,8 +11,10 @@ import org.openrndr.extra.noise.filters.*
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 200 * 6 + 200
|
||||
height = 500
|
||||
configure {
|
||||
width = 720
|
||||
height = 360
|
||||
}
|
||||
}
|
||||
program {
|
||||
val noises = listOf(
|
||||
@@ -18,7 +22,7 @@ fun main() = application {
|
||||
ValueNoise(), SimplexNoise3D(), WorleyNoise()
|
||||
)
|
||||
|
||||
val img = colorBuffer(200, 460)
|
||||
val img = colorBuffer((width - 200) / noises.size, 460)
|
||||
|
||||
val gui = GUI()
|
||||
noises.forEach { gui.add(it) }
|
||||
@@ -27,7 +31,7 @@ fun main() = application {
|
||||
extend {
|
||||
noises.forEachIndexed { i, noise ->
|
||||
noise.apply(emptyArray(), img)
|
||||
drawer.image(img, 200.0 + i * 200.0, 20.0)
|
||||
drawer.image(img, 200.0 + i * img.width, 20.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package glsl
|
||||
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.rgb
|
||||
import org.openrndr.draw.colorBuffer
|
||||
import org.openrndr.extra.noise.Random
|
||||
import org.openrndr.extra.noise.filters.*
|
||||
import org.openrndr.extra.noise.filters.SimplexNoise3D
|
||||
import org.openrndr.extra.noise.uniform
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.Vector4
|
||||
import kotlin.math.sin
|
||||
@@ -11,10 +13,10 @@ import kotlin.math.sin
|
||||
* A sine oscillator with randomized parameters
|
||||
*/
|
||||
class SinOsc {
|
||||
private val freq = Random.double(0.1, 2.0)
|
||||
private val phase = Random.double(0.0, 6.28)
|
||||
private val add = Random.double(0.0, 1.0)
|
||||
private val mul = Random.double(0.0, 1.0 - add)
|
||||
private val freq = Double.uniform(0.1, 2.0)
|
||||
private val phase = Double.uniform(0.0, 6.28)
|
||||
private val add = Double.uniform(0.0, 1.0)
|
||||
private val mul = Double.uniform(0.0, 1.0 - add)
|
||||
operator fun invoke() = sin(System.currentTimeMillis() * 0.0001 * freq + phase) * mul + add
|
||||
}
|
||||
|
||||
@@ -25,6 +27,10 @@ class SinOsc {
|
||||
* randomized sine oscillators.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 540
|
||||
}
|
||||
program {
|
||||
val noise = SimplexNoise3D()
|
||||
val img = colorBuffer(width, height)
|
||||
@@ -10,20 +10,18 @@ import org.openrndr.extra.noise.hammersley.hammersley2D
|
||||
* 400 2D Hammersley points mapped within the bounds of the application's resolution.
|
||||
* These points are visualized by rendering circles at their respective positions.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
|
||||
program {
|
||||
extend {
|
||||
val points = (0 until 400).map {
|
||||
hammersley2D(it, 400) * 720.0
|
||||
}
|
||||
drawer.circles(points, 5.0)
|
||||
program {
|
||||
extend {
|
||||
val points = (0 until 400).map {
|
||||
hammersley2D(it, 400) * 720.0
|
||||
}
|
||||
drawer.circles(points, 5.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,27 +20,25 @@ import org.openrndr.math.Vector3
|
||||
* to navigate the scene. The visualization relies on the draw loop for continuous
|
||||
* rendering of the points.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
|
||||
program {
|
||||
val sphere = sphereMesh(radius = 0.1)
|
||||
extend(Orbital())
|
||||
extend {
|
||||
val points = (0 until 1400).map {
|
||||
(hammersley3D(it, 1400) - Vector3(0.5)) * 10.0
|
||||
}
|
||||
for (point in points) {
|
||||
drawer.isolated {
|
||||
drawer.translate(point)
|
||||
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
program {
|
||||
val sphere = sphereMesh(radius = 0.1)
|
||||
extend(Orbital())
|
||||
extend {
|
||||
val points = (0 until 1400).map {
|
||||
(hammersley3D(it, 1400) - Vector3(0.5)) * 10.0
|
||||
}
|
||||
for (point in points) {
|
||||
drawer.isolated {
|
||||
drawer.translate(point)
|
||||
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,7 @@ import org.openrndr.draw.isolated
|
||||
import org.openrndr.extra.camera.Orbital
|
||||
import org.openrndr.extra.meshgenerators.sphereMesh
|
||||
import org.openrndr.extra.noise.hammersley.hammersley4D
|
||||
import org.openrndr.extra.noise.rsequence.rSeq4D
|
||||
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.
|
||||
@@ -25,28 +22,26 @@ import kotlin.math.min
|
||||
* of the scene. Rendering occurs within the draw loop, providing continuous visualization
|
||||
* of the point distribution.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
|
||||
program {
|
||||
val sphere = sphereMesh(radius = 0.1)
|
||||
extend(Orbital())
|
||||
extend {
|
||||
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)
|
||||
}
|
||||
for (point in points) {
|
||||
drawer.isolated {
|
||||
drawer.translate(point.xyz)
|
||||
drawer.fill = ColorRGBa.RED.toHSVa().shiftHue(point.w * 360.0).toRGBa()
|
||||
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
program {
|
||||
val sphere = sphereMesh(radius = 0.1)
|
||||
extend(Orbital())
|
||||
extend {
|
||||
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)
|
||||
}
|
||||
for (point in points) {
|
||||
drawer.isolated {
|
||||
drawer.translate(point.xyz)
|
||||
drawer.fill = ColorRGBa.RED.toHSVa().shiftHue(point.w * 360.0).toRGBa()
|
||||
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
30
orx-noise/src/jvmDemo/kotlin/hash/DemoCircleHash01.kt
Normal file
30
orx-noise/src/jvmDemo/kotlin/hash/DemoCircleHash01.kt
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
orx-noise/src/jvmDemo/kotlin/hash/DemoRectangleHash01.kt
Normal file
27
orx-noise/src/jvmDemo/kotlin/hash/DemoRectangleHash01.kt
Normal 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)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
26
orx-noise/src/jvmDemo/kotlin/hash/DemoUHash01.kt
Normal file
26
orx-noise/src/jvmDemo/kotlin/hash/DemoUHash01.kt
Normal 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())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,27 +2,29 @@ package phrases
|
||||
|
||||
import org.openrndr.application
|
||||
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
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
extend {
|
||||
/** A custom shadestyle */
|
||||
val ss = shadeStyle {
|
||||
fragmentPreamble = """$fhash13"""
|
||||
fragmentTransform = """
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 360
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
/** A custom shadestyle */
|
||||
val ss = shadeStyle {
|
||||
fragmentPreamble = """$fhash13"""
|
||||
fragmentTransform = """
|
||||
float cf = fhash13(vec3(c_screenPosition, p_time));
|
||||
x_fill = vec4(cf, cf, cf, 1.0);
|
||||
""".trimIndent()
|
||||
parameter("time", seconds)
|
||||
}
|
||||
drawer.shadeStyle = ss
|
||||
drawer.circle(drawer.bounds.center, 100.0)
|
||||
parameter("time", seconds)
|
||||
}
|
||||
drawer.shadeStyle = ss
|
||||
drawer.circle(drawer.bounds.center, 100.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,20 +8,18 @@ import org.openrndr.extra.noise.rsequence.rSeq2D
|
||||
* demonstrating 2D quasirandomly distributed points. The points are generated
|
||||
* using the R2 sequence and drawn as circles with a radius of 5.0.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
|
||||
program {
|
||||
extend {
|
||||
val points = (0 until 4000).map {
|
||||
rSeq2D(it) * 720.0
|
||||
}
|
||||
drawer.circles(points, 5.0)
|
||||
program {
|
||||
extend {
|
||||
val points = (0 until 4000).map {
|
||||
rSeq2D(it) * 720.0
|
||||
}
|
||||
drawer.circles(points, 5.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,27 +19,25 @@ import org.openrndr.math.Vector3
|
||||
* - Generation of quasirandom points in 3D space using the `rSeq3D` function.
|
||||
* - Transformation and rendering of each point as a sphere using vertex buffers.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
|
||||
program {
|
||||
val sphere = sphereMesh(radius = 0.1)
|
||||
extend(Orbital())
|
||||
extend {
|
||||
val points = (0 until 1400).map {
|
||||
(rSeq3D(it) - Vector3(0.5)) * 10.0
|
||||
}
|
||||
for (point in points) {
|
||||
drawer.isolated {
|
||||
drawer.translate(point)
|
||||
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
program {
|
||||
val sphere = sphereMesh(radius = 0.1)
|
||||
extend(Orbital())
|
||||
extend {
|
||||
val points = (0 until 1400).map {
|
||||
(rSeq3D(it) - Vector3(0.5)) * 10.0
|
||||
}
|
||||
for (point in points) {
|
||||
drawer.isolated {
|
||||
drawer.translate(point)
|
||||
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,28 +27,26 @@ import kotlin.math.min
|
||||
* of the point and its color calculated by shifting the hue of a base color using
|
||||
* the w-coordinate value.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
|
||||
program {
|
||||
val sphere = sphereMesh(radius = 0.1)
|
||||
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)
|
||||
}
|
||||
extend(Orbital())
|
||||
extend {
|
||||
for (point in points) {
|
||||
drawer.isolated {
|
||||
drawer.translate(point.xyz)
|
||||
drawer.fill = ColorRGBa.RED.toHSVa().shiftHue(point.w * 360.0).toRGBa()
|
||||
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
program {
|
||||
val sphere = sphereMesh(radius = 0.1)
|
||||
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)
|
||||
}
|
||||
extend(Orbital())
|
||||
extend {
|
||||
for (point in points) {
|
||||
drawer.isolated {
|
||||
drawer.translate(point.xyz)
|
||||
drawer.fill = ColorRGBa.RED.toHSVa().shiftHue(point.w * 360.0).toRGBa()
|
||||
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user