Add vector based noise functions

This commit is contained in:
Abe Pazos
2020-04-23 18:46:05 +02:00
committed by Edwin Jakobs
parent a28f298690
commit 400347aad1
12 changed files with 278 additions and 4 deletions

View File

@@ -1,10 +1,17 @@
package org.openrndr.extra.noise
import org.openrndr.math.Vector2
fun perlin(seed: Int, x: Double, y: Double) = perlin(seed, x, y, ::linear)
fun perlinLinear(seed: Int, x: Double, y: Double) = perlin(seed, x, y, ::linear)
fun perlinQuintic(seed: Int, x: Double, y: Double) = perlin(seed, x, y, ::quintic)
fun perlinHermite(seed: Int, x: Double, y: Double) = perlin(seed, x, y, ::hermite)
fun perlin(seed: Int, position: Vector2) = perlin(seed, position.x, position.y, ::linear)
fun perlinLinear(seed: Int, position: Vector2) = perlin(seed, position.x, position.y, ::linear)
fun perlinQuintic(seed: Int, position: Vector2) = perlin(seed, position.x, position.y, ::quintic)
fun perlinHermite(seed: Int, position: Vector2) = perlin(seed, position.x, position.y, ::hermite)
inline fun perlin(seed: Int, x: Double, y: Double, crossinline interpolator: (Double) -> Double): Double {
val x0 = x.fastFloor()
val y0 = y.fastFloor()