-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathDemoDifferencing01.kt
40 lines (35 loc) · 1.37 KB
/
DemoDifferencing01.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
import difference.differencing
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.delegatemagic.aggregation.aggregating
import org.openrndr.extra.delegatemagic.aggregation.maxMag
import org.openrndr.extra.delegatemagic.tracking.tracking
import org.openrndr.extra.gui.GUI
import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector2
fun main() {
application {
program {
val gui = GUI()
val state = object {
@DoubleParameter("radius", 0.0, 200.0)
var radius = 100.0
val difference by differencing(::radius)
val differenceHistory by tracking(::difference)
val differenceMax by aggregating(::differenceHistory) {
it.maxMag()
}
}
gui.add(state, "state")
extend(gui)
extend {
drawer.circle(drawer.bounds.center, state.radius)
drawer.stroke = ColorRGBa.GREEN
drawer.lineSegment(drawer.bounds.center, drawer.bounds.center + Vector2(state.difference, 0.0))
drawer.translate(0.0, 4.0)
drawer.stroke = ColorRGBa.BLUE
drawer.lineSegment(drawer.bounds.center, drawer.bounds.center + Vector2(state.differenceMax, 0.0))
}
}
}
}