-
Notifications
You must be signed in to change notification settings - Fork 37
/
DemoStraightSkeleton01.kt
47 lines (44 loc) · 1.68 KB
/
DemoStraightSkeleton01.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.color.ColorRGBa
import org.openrndr.draw.ColorType
import org.openrndr.draw.createEquivalent
import org.openrndr.draw.isolatedWithTarget
import org.openrndr.draw.renderTarget
import org.openrndr.extra.jumpfill.fx.StraightSkeleton
import org.openrndr.extra.noise.simplex
fun main() {
application {
configure {
width = 1280
height = 720
}
program {
val straightSkeleton = StraightSkeleton()
val input = renderTarget(width, height) {
colorBuffer()
}
val field = input.colorBuffer(0).createEquivalent(type = ColorType.FLOAT32)
extend {
drawer.isolatedWithTarget(input) {
// -- draw something interesting
drawer.stroke = null
drawer.clear(ColorRGBa.BLACK)
drawer.fill = ColorRGBa.WHITE
drawer.circle(mouse.position, 300.0)
drawer.fill = ColorRGBa.BLACK
drawer.circle(mouse.position, 150.0)
drawer.fill = ColorRGBa.WHITE
for (i in 0 until 30) {
val time = seconds * 0.25
val x = simplex(i * 20, time) * width / 2 + width / 2
val y = simplex(i * 20 + 5, time) * height / 2 + height / 2
val r = simplex(i*30, time) * 50.0 + 50.0
drawer.circle(x, y, r)
}
}
straightSkeleton.apply(input.colorBuffer(0), field)
drawer.image(field)
}
}
}
}