[orx-delegate-magic, orx-envelopes] Add orx-delegate-magic, orx-envelopes
This commit is contained in:
29
orx-delegate-magic/src/jvmDemo/kotlin/DemoSmoothing01.kt
Normal file
29
orx-delegate-magic/src/jvmDemo/kotlin/DemoSmoothing01.kt
Normal file
@@ -0,0 +1,29 @@
|
||||
import org.openrndr.application
|
||||
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 smoothing(state::x)
|
||||
val sy by smoothing(state::y)
|
||||
val sradius by smoothing(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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user