[orx-noise] Add gradient and crossFade tools

This commit is contained in:
Edwin Jakobs
2021-07-26 20:14:30 +02:00
parent 454affbdfd
commit 32e81a82c5
4 changed files with 98 additions and 16 deletions

View File

@@ -1,14 +1,19 @@
package org.openrndr.extra.noise
import org.openrndr.math.Polar
import org.openrndr.math.Vector2
import kotlin.jvm.JvmName
fun ((Int, Double) -> Double).vector2(): (seed: Int, x: Double) -> Vector2 {
val ref = this
return { seed:Int, x:Double ->
Vector2(ref(-seed, x), ref(seed, -x))
}
}
@JvmName("polarWithVector2Output")
fun ((Int, Polar) -> Double).withVector2Output(): (Int, Polar) -> Vector2 =
{ seed, polar -> Vector2(this(seed, polar), this(seed xor 0x7f7f7f7f, Polar(-polar.theta, polar.radius))) }
fun ((Int, Double) -> Double).withVector2Output(): (seed: Int, x: Double) -> Vector2 =
{ seed: Int, x: Double -> Vector2(this(seed, x), this(seed xor 0x7f7f7f7f, -x)) }
fun ((Int, Double, Double) -> Double).withVector2Output(): (seed: Int, x: Double, y: Double) -> Vector2 =
{ seed, x, y -> Vector2(this(seed, x, y), this(seed xor 0x7f7f7f7f, y, -x)) }
fun ((Int, Double, Double, Double) -> Double).withVector2Output(): (seed: Int, x: Double, y: Double, z: Double) -> Vector2 =
{ seed, x, y, z -> Vector2(this(seed, x, y, z), this(seed xor 0x7f7f7f7f, y, -x, z)) }
private fun exampleVector() {
::simplex2D
}