-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathDemoVoronoi02.kt
56 lines (45 loc) · 1.61 KB
/
DemoVoronoi02.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
48
49
50
51
52
53
54
55
56
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.*
import org.openrndr.extra.color.colormatrix.tint
import org.openrndr.extra.jumpfill.*
import kotlin.math.cos
fun main() = application {
configure {
width = 512
height = 512
}
program {
val rt = renderTarget(width, height, 1.0) {
colorBuffer(type = ColorType.FLOAT32)
}
val flowfield = colorBuffer(width, height, type = ColorType.FLOAT32)
val cluster = ClusteredField(decodeMode = DecodeMode.DISTANCE, outputDistanceToContours = true)
cluster.normalizedDistance = true
extend {
fun plot(x: Double, y: Double, id: Double) {
drawer.fill = ColorRGBa(id, 0.0, 0.0, 1.0)
drawer.point(x, y)
}
drawer.isolatedWithTarget(rt) {
drawer.clear(ColorRGBa(-1.0, -1.0, -1.0, 0.0))
val o = cos(seconds) * 200.0 + 200.0
for (i in 0 until 20) {
plot(o + 100.0 + i * 4, 100.0, 0.25)
}
for (i in 0 until 20) {
plot(200.0 + i * 4, 150.0 + i, 0.5)
}
for (i in 0 until 20) {
plot(300.0 + i * 4, 250.0 + i, 0.7)
}
for (i in 0 until 20) {
plot(400.0 + i * 4, 250.0 + i, 0.75)
}
}
cluster.apply(rt.colorBuffer(0), flowfield)
drawer.drawStyle.colorMatrix = tint(ColorRGBa(10.0, 10.0, 1.0))
drawer.image(flowfield)
}
}
}