-
Notifications
You must be signed in to change notification settings - Fork 37
/
DemoScrub01.kt
47 lines (43 loc) · 1.42 KB
/
DemoScrub01.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import org.openrndr.application
import org.openrndr.extensions.SingleScreenshot
import org.openrndr.extra.keyframer.Keyframer
import org.openrndr.panel.controlManager
import org.openrndr.panel.elements.Range
import org.openrndr.panel.elements.Slider
import org.openrndr.panel.elements.slider
import org.openrndr.resourceUrl
import java.net.URL
fun main() = application {
program {
// -- replace the default clock with an offset clock
var clockOffset = 0.0
val oldClock = clock
clock = { oldClock() - clockOffset }
var clockSlider: Slider? = null
// -- setup a simple UI
val cm = controlManager {
layout {
clockSlider = slider {
range = Range(0.0, 30.0)
events.valueChanged.listen {
if (it.interactive) {
clockOffset = oldClock() - it.newValue
}
}
}
}
}
extend(cm)
class Animation: Keyframer() {
val position by Vector2Channel(arrayOf("x", "y"))
}
val animation = Animation()
animation.loadFromJson(URL(resourceUrl("/demo-simple-01.json")))
extend {
// -- update the slider
clockSlider?.value = seconds
animation(seconds)
drawer.circle(animation.position, 100.0)
}
}
}