forked from openrndr/orx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DemoEnvelope.kt
46 lines (39 loc) · 1.38 KB
/
DemoEnvelope.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
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.isolated
import org.openrndr.extensions.SingleScreenshot
import org.openrndr.extra.timeoperators.Envelope
import org.openrndr.extra.timeoperators.TimeOperators
fun main() {
application {
program {
val size = Envelope(50.0, 400.0, 0.5, 0.5)
val rotation = Envelope(easingFactor = 0.4)
if (System.getProperty("takeScreenshot") == "true") {
extend(SingleScreenshot()) {
this.outputFile = System.getProperty("screenshotPath")
}
}
extend(TimeOperators()) {
track(size, rotation)
}
extend {
if (frameCount % 80 == 0) {
size.trigger()
}
if (frameCount % 50 == 0) {
rotation.trigger(180.0)
}
drawer.isolated {
drawer.stroke = ColorRGBa.PINK
drawer.fill = ColorRGBa.PINK
drawer.translate(width / 2.0, height / 2.0)
drawer.rotate(rotation.value)
val side = size.value / 2.0
val offset = side / 2.0
drawer.rectangle(0.0 - offset, 0.0 - offset, side, side)
}
}
}
}
}