[orx-delegate-magic, orx-envelopes] Add orx-delegate-magic, orx-envelopes

This commit is contained in:
Edwin Jakobs
2023-04-21 12:32:59 +02:00
parent a61edcbbf7
commit 9119e4a95a
14 changed files with 576 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import org.openrndr.application
import org.openrndr.extra.delegatemagic.dynamics.springForcing
import org.openrndr.extra.delegatemagic.smoothing.smoothing
import kotlin.random.Random
fun main() = application {
program {
val state = object {
var x = width / 2.0
var y = height / 2.0
var radius = 5.0
}
val sx by springForcing(state::x, k = 10.0)
val sy by springForcing(state::y)
val sradius by springForcing(state::radius)
extend {
if (Random.nextDouble() < 0.01) {
state.radius = Random.nextDouble(10.0, 200.0)
}
if (Random.nextDouble() < 0.01) {
state.x = Random.nextDouble(0.0, width.toDouble())
}
if (Random.nextDouble() < 0.01) {
state.y = Random.nextDouble(10.0, height.toDouble())
}
drawer.circle(sx, sy, sradius)
}
}
}