Skip to content

Commit

Permalink
[orx-noise] Replace hash functions
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinRNDR committed Oct 19, 2024
1 parent 8a18546 commit 8690793
Show file tree
Hide file tree
Showing 10 changed files with 181 additions and 126 deletions.
8 changes: 4 additions & 4 deletions orx-noise/src/commonMain/kotlin/CubicNoise2D.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ fun cubic(seed: Int, x: Double, y: Double, interpolator: (Double) -> Double = ::
val ys = interpolator(y - y1.toDouble())

return cubic(
cubic(valCoord2D(seed, x0, y0), valCoord2D(seed, x1, y0), valCoord2D(seed, x2, y0), valCoord2D(seed, x3, y0),
cubic(fshash2D(seed, x0, y0), fshash2D(seed, x1, y0), fshash2D(seed, x2, y0), fshash2D(seed, x3, y0),
xs),
cubic(valCoord2D(seed, x0, y1), valCoord2D(seed, x1, y1), valCoord2D(seed, x2, y1), valCoord2D(seed, x3, y1),
cubic(fshash2D(seed, x0, y1), fshash2D(seed, x1, y1), fshash2D(seed, x2, y1), fshash2D(seed, x3, y1),
xs),
cubic(valCoord2D(seed, x0, y2), valCoord2D(seed, x1, y2), valCoord2D(seed, x2, y2), valCoord2D(seed, x3, y2),
cubic(fshash2D(seed, x0, y2), fshash2D(seed, x1, y2), fshash2D(seed, x2, y2), fshash2D(seed, x3, y2),
xs),
cubic(valCoord2D(seed, x0, y3), valCoord2D(seed, x1, y3), valCoord2D(seed, x2, y3), valCoord2D(seed, x3, y3),
cubic(fshash2D(seed, x0, y3), fshash2D(seed, x1, y3), fshash2D(seed, x2, y3), fshash2D(seed, x3, y3),
xs),
ys) * CUBIC_2D_BOUNDING
}
Expand Down
32 changes: 16 additions & 16 deletions orx-noise/src/commonMain/kotlin/CubicNoise3D.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,28 @@ fun cubic(seed: Int, x: Double, y: Double, z: Double, interpolator: (Double) ->

return cubic(
cubic(
cubic(valCoord3D(seed, x0, y0, z0), valCoord3D(seed, x1, y0, z0), valCoord3D(seed, x2, y0, z0), valCoord3D(seed, x3, y0, z0), xs),
cubic(valCoord3D(seed, x0, y1, z0), valCoord3D(seed, x1, y1, z0), valCoord3D(seed, x2, y1, z0), valCoord3D(seed, x3, y1, z0), xs),
cubic(valCoord3D(seed, x0, y2, z0), valCoord3D(seed, x1, y2, z0), valCoord3D(seed, x2, y2, z0), valCoord3D(seed, x3, y2, z0), xs),
cubic(valCoord3D(seed, x0, y3, z0), valCoord3D(seed, x1, y3, z0), valCoord3D(seed, x2, y3, z0), valCoord3D(seed, x3, y3, z0), xs),
cubic(fshash3D(seed, x0, y0, z0), fshash3D(seed, x1, y0, z0), fshash3D(seed, x2, y0, z0), fshash3D(seed, x3, y0, z0), xs),
cubic(fshash3D(seed, x0, y1, z0), fshash3D(seed, x1, y1, z0), fshash3D(seed, x2, y1, z0), fshash3D(seed, x3, y1, z0), xs),
cubic(fshash3D(seed, x0, y2, z0), fshash3D(seed, x1, y2, z0), fshash3D(seed, x2, y2, z0), fshash3D(seed, x3, y2, z0), xs),
cubic(fshash3D(seed, x0, y3, z0), fshash3D(seed, x1, y3, z0), fshash3D(seed, x2, y3, z0), fshash3D(seed, x3, y3, z0), xs),
ys),
cubic(
cubic(valCoord3D(seed, x0, y0, z1), valCoord3D(seed, x1, y0, z1), valCoord3D(seed, x2, y0, z1), valCoord3D(seed, x3, y0, z1), xs),
cubic(valCoord3D(seed, x0, y1, z1), valCoord3D(seed, x1, y1, z1), valCoord3D(seed, x2, y1, z1), valCoord3D(seed, x3, y1, z1), xs),
cubic(valCoord3D(seed, x0, y2, z1), valCoord3D(seed, x1, y2, z1), valCoord3D(seed, x2, y2, z1), valCoord3D(seed, x3, y2, z1), xs),
cubic(valCoord3D(seed, x0, y3, z1), valCoord3D(seed, x1, y3, z1), valCoord3D(seed, x2, y3, z1), valCoord3D(seed, x3, y3, z1), xs),
cubic(fshash3D(seed, x0, y0, z1), fshash3D(seed, x1, y0, z1), fshash3D(seed, x2, y0, z1), fshash3D(seed, x3, y0, z1), xs),
cubic(fshash3D(seed, x0, y1, z1), fshash3D(seed, x1, y1, z1), fshash3D(seed, x2, y1, z1), fshash3D(seed, x3, y1, z1), xs),
cubic(fshash3D(seed, x0, y2, z1), fshash3D(seed, x1, y2, z1), fshash3D(seed, x2, y2, z1), fshash3D(seed, x3, y2, z1), xs),
cubic(fshash3D(seed, x0, y3, z1), fshash3D(seed, x1, y3, z1), fshash3D(seed, x2, y3, z1), fshash3D(seed, x3, y3, z1), xs),
ys),
cubic(
cubic(valCoord3D(seed, x0, y0, z2), valCoord3D(seed, x1, y0, z2), valCoord3D(seed, x2, y0, z2), valCoord3D(seed, x3, y0, z2), xs),
cubic(valCoord3D(seed, x0, y1, z2), valCoord3D(seed, x1, y1, z2), valCoord3D(seed, x2, y1, z2), valCoord3D(seed, x3, y1, z2), xs),
cubic(valCoord3D(seed, x0, y2, z2), valCoord3D(seed, x1, y2, z2), valCoord3D(seed, x2, y2, z2), valCoord3D(seed, x3, y2, z2), xs),
cubic(valCoord3D(seed, x0, y3, z2), valCoord3D(seed, x1, y3, z2), valCoord3D(seed, x2, y3, z2), valCoord3D(seed, x3, y3, z2), xs),
cubic(fshash3D(seed, x0, y0, z2), fshash3D(seed, x1, y0, z2), fshash3D(seed, x2, y0, z2), fshash3D(seed, x3, y0, z2), xs),
cubic(fshash3D(seed, x0, y1, z2), fshash3D(seed, x1, y1, z2), fshash3D(seed, x2, y1, z2), fshash3D(seed, x3, y1, z2), xs),
cubic(fshash3D(seed, x0, y2, z2), fshash3D(seed, x1, y2, z2), fshash3D(seed, x2, y2, z2), fshash3D(seed, x3, y2, z2), xs),
cubic(fshash3D(seed, x0, y3, z2), fshash3D(seed, x1, y3, z2), fshash3D(seed, x2, y3, z2), fshash3D(seed, x3, y3, z2), xs),
ys),
cubic(
cubic(valCoord3D(seed, x0, y0, z3), valCoord3D(seed, x1, y0, z3), valCoord3D(seed, x2, y0, z3), valCoord3D(seed, x3, y0, z3), xs),
cubic(valCoord3D(seed, x0, y1, z3), valCoord3D(seed, x1, y1, z3), valCoord3D(seed, x2, y1, z3), valCoord3D(seed, x3, y1, z3), xs),
cubic(valCoord3D(seed, x0, y2, z3), valCoord3D(seed, x1, y2, z3), valCoord3D(seed, x2, y2, z3), valCoord3D(seed, x3, y2, z3), xs),
cubic(valCoord3D(seed, x0, y3, z3), valCoord3D(seed, x1, y3, z3), valCoord3D(seed, x2, y3, z3), valCoord3D(seed, x3, y3, z3), xs),
cubic(fshash3D(seed, x0, y0, z3), fshash3D(seed, x1, y0, z3), fshash3D(seed, x2, y0, z3), fshash3D(seed, x3, y0, z3), xs),
cubic(fshash3D(seed, x0, y1, z3), fshash3D(seed, x1, y1, z3), fshash3D(seed, x2, y1, z3), fshash3D(seed, x3, y1, z3), xs),
cubic(fshash3D(seed, x0, y2, z3), fshash3D(seed, x1, y2, z3), fshash3D(seed, x2, y2, z3), fshash3D(seed, x3, y2, z3), xs),
cubic(fshash3D(seed, x0, y3, z3), fshash3D(seed, x1, y3, z3), fshash3D(seed, x2, y3, z3), fshash3D(seed, x3, y3, z3), xs),
ys),
zs) * CUBIC_3D_BOUNDING
}
Expand Down
80 changes: 5 additions & 75 deletions orx-noise/src/commonMain/kotlin/GradCoord.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,43 +20,24 @@ private val GRAD_3D = arrayOf(
Vector3(1.0, 1.0, 0.0), Vector3(0.0, -1.0, 1.0), Vector3(-1.0, 1.0, 0.0), Vector3(0.0, -1.0, -1.0))

fun gradCoord2D(seed: Int, x: Int, y: Int, xd: Double, yd: Double): Double {
var hash = seed
hash = hash xor X_PRIME * x
hash = hash xor Y_PRIME * y
val hash = uhash2D(seed, x, y)

hash = hash * hash * hash * 60493
hash = hash shr 13 xor hash

val (x1, y1) = GRAD_2D[hash and 7]
val (x1, y1) = GRAD_2D[(hash and 7U).toInt()]

return xd * x1 + yd * y1
}

fun gradCoord3D(seed: Int, x: Int, y: Int, z: Int, xd: Double, yd: Double, zd: Double): Double {
var hash = seed
hash = hash xor X_PRIME * x
hash = hash xor Y_PRIME * y
hash = hash xor Z_PRIME * z

hash *= hash * hash * 60493
hash = hash shr 13 xor hash
val hash = uhash3D(seed, x, y, z)

val g = GRAD_3D[hash and 15]
val g = GRAD_3D[(hash and 15U).toInt()]

return xd * g.x + yd * g.y + zd * g.z
}

fun gradCoord4D(seed: Int, x: Int, y: Int, z: Int, w: Int, xd: Double, yd: Double, zd: Double, wd: Double): Double {
var hash = seed
hash = hash xor X_PRIME * x
hash = hash xor Y_PRIME * y
hash = hash xor Z_PRIME * z
hash = hash xor W_PRIME * w
val hash = (uhash4D(seed, x, y, z, w) and 31U).toInt()

hash = hash * hash * hash * 60493
hash = hash shr 13 xor hash

hash = hash and 31
var a = yd
var b = zd
var c = wd // X,Y,Z
Expand All @@ -83,57 +64,6 @@ fun gradCoord4D(seed: Int, x: Int, y: Int, z: Int, w: Int, xd: Double, yd: Doubl
return (if (hash and 4 == 0) -a else a) + (if (hash and 2 == 0) -b else b) + if (hash and 1 == 0) -c else c
}


fun hash2D(seed: Int, x: Int, y: Int): Int {
var hash = seed
hash = hash xor X_PRIME * x
hash = hash xor Y_PRIME * y

hash = hash * hash * hash * 60493
hash = hash shr 13 xor hash

return hash
}

fun hash3D(seed: Int, x: Int, y: Int, z: Int): Int {
var hash = seed
hash = hash xor X_PRIME * x
hash = hash xor Y_PRIME * y
hash = hash xor Z_PRIME * z

hash = hash * hash * hash * 60493
hash = hash shr 13 xor hash

return hash
}

fun hash4D(seed: Int, x: Int, y: Int, z: Int, w: Int): Int {
var hash = seed
hash = hash xor X_PRIME * x
hash = hash xor Y_PRIME * y
hash = hash xor Z_PRIME * z
hash = hash xor W_PRIME * w

hash = hash * hash * hash * 60493
hash = hash shr 13 xor hash
return hash
}


fun valCoord1D(seed: Int, x: Int): Double {
var n = seed
n = n xor X_PRIME * x
return n * n * n * 60493 / 2147483648.0
}

fun valCoord2D(seed: Int, x: Int, y: Int): Double {
var n = seed
n = n xor X_PRIME * x
n = n xor Y_PRIME * y

return n * n * n * 60493 / 2147483648.0
}

fun valCoord3D(seed: Int, x: Int, y: Int, z: Int): Double {
var n = seed
n = n xor X_PRIME * x
Expand Down
66 changes: 41 additions & 25 deletions orx-noise/src/commonMain/kotlin/GradientPerturb.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import org.openrndr.math.Vector2
import org.openrndr.math.Vector3
import org.openrndr.math.mix

fun gradientPerturbFractal(seed: Int, amplitude: Double = 1.0, frequency: Double = 2.0,
lacunarity: Double = 2.0, gain: Double = 0.5,
octaves: Int = 4, position: Vector3, interpolator: (Double) -> Double = ::quintic): Vector3 {
fun gradientPerturbFractal(
seed: Int, amplitude: Double = 1.0, frequency: Double = 2.0,
lacunarity: Double = 2.0, gain: Double = 0.5,
octaves: Int = 4, position: Vector3, interpolator: (Double) -> Double = ::quintic
): Vector3 {

var seed_ = seed
var amplitude_ = amplitude
Expand All @@ -22,7 +24,13 @@ fun gradientPerturbFractal(seed: Int, amplitude: Double = 1.0, frequency: Double
return p
}

fun gradientPerturb(seed: Int, amplitude: Double, frequency: Double, position: Vector3, interpolator: (Double) -> Double = ::quintic): Vector3 {
fun gradientPerturb(
seed: Int,
amplitude: Double,
frequency: Double,
position: Vector3,
interpolator: (Double) -> Double = ::quintic
): Vector3 {
val xf = position.x * frequency
val yf = position.y * frequency
val zf = position.z * frequency
Expand All @@ -38,15 +46,15 @@ fun gradientPerturb(seed: Int, amplitude: Double, frequency: Double, position: V
val ys = interpolator(yf - y0)
val zs = interpolator(zf - z0)

var vec0 = Cell3D[hash3D(seed, x0, y0, z0) and 0xff]
var vec1 = Cell3D[hash3D(seed, x1, y0, z0) and 0xff]
var vec0 = Cell3D[(uhash3D(seed, x0, y0, z0) and 0xffU).toInt()]
var vec1 = Cell3D[(uhash3D(seed, x1, y0, z0) and 0xffU).toInt()]

var lx0x = mix(vec0.x, vec1.x, xs)
var ly0x = mix(vec0.y, vec1.y, xs)
var lz0x = mix(vec0.z, vec1.z, xs)

vec0 = Cell3D[hash3D(seed, x0, y1, z0) and 0xff]
vec1 = Cell3D[hash3D(seed, x1, y1, z0) and 0xff]
vec0 = Cell3D[(uhash3D(seed, x0, y1, z0) and 0xffU).toInt()]
vec1 = Cell3D[(uhash3D(seed, x1, y1, z0) and 0xffU).toInt()]

var lx1x = mix(vec0.x, vec1.x, xs)
var ly1x = mix(vec0.y, vec1.y, xs)
Expand All @@ -56,30 +64,32 @@ fun gradientPerturb(seed: Int, amplitude: Double, frequency: Double, position: V
val ly0y = mix(ly0x, ly1x, ys)
val lz0y = mix(lz0x, lz1x, ys)

vec0 = Cell3D[hash3D(seed, x0, y0, z1) and 0xff]
vec1 = Cell3D[hash3D(seed, x1, y0, z1) and 0xff]
vec0 = Cell3D[(uhash3D(seed, x0, y0, z1) and 0xffU).toInt()]
vec1 = Cell3D[(uhash3D(seed, x1, y0, z1) and 0xffU).toInt()]

lx0x = mix(vec0.x, vec1.x, xs)
ly0x = mix(vec0.y, vec1.y, xs)
lz0x = mix(vec0.z, vec1.z, xs)

vec0 = Cell3D[hash3D(seed, x0, y1, z1) and 0xff]
vec1 = Cell3D[hash3D(seed, x1, y1, z1) and 0xff]
vec0 = Cell3D[(uhash3D(seed, x0, y1, z1) and 0xffU).toInt()]
vec1 = Cell3D[(uhash3D(seed, x1, y1, z1) and 0xffU).toInt()]

lx1x = mix(vec0.x, vec1.x, xs)
ly1x = mix(vec0.y, vec1.y, xs)
lz1x = mix(vec0.z, vec1.z, xs)

return position + Vector3(
mix(lx0y, mix(lx0x, lx1x, ys), zs),
mix(ly0y, mix(ly0x, ly1x, ys), zs),
mix(lz0y, mix(lz0x, lz1x, ys), zs)
mix(lx0y, mix(lx0x, lx1x, ys), zs),
mix(ly0y, mix(ly0x, ly1x, ys), zs),
mix(lz0y, mix(lz0x, lz1x, ys), zs)
) * amplitude
}

fun gradientPerturbFractal(seed: Int, amplitude: Double = 1.0, frequency: Double = 2.0,
lacunarity: Double = 2.0, gain: Double = 0.5,
octaves: Int = 4, position: Vector2, interpolator: (Double) -> Double = ::quintic): Vector2 {
fun gradientPerturbFractal(
seed: Int, amplitude: Double = 1.0, frequency: Double = 2.0,
lacunarity: Double = 2.0, gain: Double = 0.5,
octaves: Int = 4, position: Vector2, interpolator: (Double) -> Double = ::quintic
): Vector2 {

var seed_ = seed
var amplitude_ = amplitude
Expand All @@ -95,7 +105,13 @@ fun gradientPerturbFractal(seed: Int, amplitude: Double = 1.0, frequency: Double
return p
}

fun gradientPerturb(seed: Int, amplitude: Double, frequency: Double, position: Vector2, interpolator: (Double) -> Double = ::quintic): Vector2 {
fun gradientPerturb(
seed: Int,
amplitude: Double,
frequency: Double,
position: Vector2,
interpolator: (Double) -> Double = ::quintic
): Vector2 {
val xf = position.x * frequency
val yf = position.y * frequency
val x0 = xf.fastFloor()
Expand All @@ -106,21 +122,21 @@ fun gradientPerturb(seed: Int, amplitude: Double, frequency: Double, position: V
val xs = interpolator(xf - x0)
val ys = interpolator(yf - y0)

var vec0 = Cell2D[hash2D(seed, x0, y0) and 0xff]
var vec1 = Cell2D[hash2D(seed, x1, y0) and 0xff]
var vec0 = Cell2D[(uhash2D(seed, x0, y0) and 0xffU).toInt()]
var vec1 = Cell2D[(uhash2D(seed, x1, y0) and 0xffU).toInt()]

val lx0x = mix(vec0.x, vec1.x, xs)
val ly0x = mix(vec0.y, vec1.y, xs)

vec0 = Cell2D[hash2D(seed, x0, y1) and 0xff]
vec1 = Cell2D[hash2D(seed, x1, y1) and 0xff]
vec0 = Cell2D[(uhash2D(seed, x0, y1) and 0xffU).toInt()]
vec1 = Cell2D[(uhash2D(seed, x1, y1) and 0xffU).toInt()]

val lx1x = mix(vec0.x, vec1.x, xs)
val ly1x = mix(vec0.y, vec1.y, xs)

return position + Vector2(
mix(lx0x, lx1x, ys),
mix(ly0x, ly1x, ys)
mix(lx0x, lx1x, ys),
mix(ly0x, ly1x, ys)
) * amplitude

}
41 changes: 41 additions & 0 deletions orx-noise/src/commonMain/kotlin/UHash.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.openrndr.extra.noise

/**
* uniform hash function
* https://nullprogram.com/blog/2018/07/31/
*/
fun uhash11(x: UInt): UInt {
var a = x
a = a xor (a shr 16)
a *= 0x7feb352du
a = a xor (a shr 15)
a *= 0x846ca68bu
a = a xor (a shr 16)
return a
}

fun uhash1D(seed: Int, x: Int): UInt = uhash11(seed.toUInt() + uhash11(x.toUInt()))
fun uhash2D(seed: Int, x: Int, y: Int): UInt = uhash11(seed.toUInt() + uhash11(y.toUInt() + uhash11(x.toUInt())))
fun uhash3D(seed: Int, x: Int, y: Int, z: Int): UInt =
uhash11(seed.toUInt() + uhash11(z.toUInt() + uhash11(x.toUInt() + uhash11(y.toUInt()))))

fun uhash4D(seed: Int, x: Int, y: Int, z: Int, w: Int): UInt =
uhash11(seed.toUInt() + uhash11(z.toUInt() + uhash11(z.toUInt() + uhash11(x.toUInt() + uhash11(y.toUInt())))))


fun fhash1D(seed: Int, x: Int): Double = uhash1D(seed, x).toDouble() / UInt.MAX_VALUE.toDouble()
fun fhash2D(seed: Int, x: Int, y: Int): Double = uhash2D(seed, x, y).toDouble() / UInt.MAX_VALUE.toDouble()
fun fhash3D(seed: Int, x: Int, y: Int, z: Int): Double =
uhash3D(seed, x, y, z).toDouble() / UInt.MAX_VALUE.toDouble()

fun fhash4D(seed: Int, x: Int, y: Int, z: Int, w :Int): Double =
uhash4D(seed, x, y, z, w).toDouble() / UInt.MAX_VALUE.toDouble()


fun fshash1D(seed: Int, x: Int): Double = 2.0 * uhash1D(seed, x).toDouble() / UInt.MAX_VALUE.toDouble() - 1.0
fun fshash2D(seed: Int, x: Int, y: Int): Double = 2.0 * uhash2D(seed, x, y).toDouble() / UInt.MAX_VALUE.toDouble() - 1.0
fun fshash3D(seed: Int, x: Int, y: Int, z: Int): Double =
2.0*uhash3D(seed, x, y, z).toDouble() / UInt.MAX_VALUE.toDouble() - 1.0

fun fshash4D(seed: Int, x: Int, y: Int, z: Int, w :Int): Double =
2.0 * uhash4D(seed, x, y, z, w).toDouble() / UInt.MAX_VALUE.toDouble() - 1.0
4 changes: 2 additions & 2 deletions orx-noise/src/commonMain/kotlin/ValueNoise2D.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ inline fun value(seed: Int, x: Double, y: Double, crossinline interpolation: (Do
val xs = interpolation(x - x0)
val ys = interpolation(y - y0)

val xf0 = mix(valCoord2D(seed, x0, y0), valCoord2D(seed, x1, y0), xs)
val xf1 = mix(valCoord2D(seed, x0, y1), valCoord2D(seed, x1, y1), xs)
val xf0 = mix(fshash2D(seed, x0, y0), fshash2D(seed, x1, y0), xs)
val xf1 = mix(fshash2D(seed, x0, y1), fshash2D(seed, x1, y1), xs)

return mix(xf0, xf1, ys)
}
Expand Down
8 changes: 4 additions & 4 deletions orx-noise/src/commonMain/kotlin/ValueNoise3D.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ inline fun value(seed: Int, x: Double, y: Double, z: Double, crossinline interpo
val ys = interpolation(y - y0)
val zs = interpolation(z - z0)

val xf00 = mix(fshash3D(seed, x0, y0, z0), fshash3D(seed, x1, y0, z0), xs)
val xf10 = mix(fshash3D(seed, x0, y1, z0), fshash3D(seed, x1, y1, z0), xs)
val xf01 = mix(fshash3D(seed, x0, y0, z1), fshash3D(seed, x1, y0, z1), xs)
val xf11 = mix(fshash3D(seed, x0, y1, z1), fshash3D(seed, x1, y1, z1), xs)

val xf00 = mix(valCoord3D(seed, x0, y0, z0), valCoord3D(seed, x1, y0, z0), xs)
val xf10 = mix(valCoord3D(seed, x0, y1, z0), valCoord3D(seed, x1, y1, z0), xs)
val xf01 = mix(valCoord3D(seed, x0, y0, z1), valCoord3D(seed, x1, y0, z1), xs)
val xf11 = mix(valCoord3D(seed, x0, y1, z1), valCoord3D(seed, x1, y1, z1), xs)

val yf0 = mix(xf00, xf10, ys)
val yf1 = mix(xf01, xf11, ys)
Expand Down
21 changes: 21 additions & 0 deletions orx-noise/src/jvmDemo/kotlin/DemoCubicNoise2D01.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
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 = 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())
}
}
}
}
}
}
}
Loading

0 comments on commit 8690793

Please sign in to comment.