-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathDemoShapeSDF02.kt
62 lines (51 loc) · 2 KB
/
DemoShapeSDF02.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
57
58
59
60
61
62
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.ColorFormat
import org.openrndr.draw.ColorType
import org.openrndr.draw.colorBuffer
import org.openrndr.extra.jumpfill.ShapeSDF
import org.openrndr.extra.jumpfill.draw.SDFStrokeFill
import org.openrndr.extra.jumpfill.ops.SDFOnion
import org.openrndr.extra.jumpfill.ops.SDFSmoothIntersection
import org.openrndr.extra.svg.loadSVG
import org.openrndr.math.Vector3
import org.openrndr.math.transforms.transform
import kotlin.math.min
fun main() {
application {
configure {
width = 1280
height = 720
}
program {
val sdf0 = ShapeSDF()
val df0 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val sdf1 = ShapeSDF()
val df1 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
val union = SDFSmoothIntersection()
val onion = SDFOnion()
val strokeFill = SDFStrokeFill()
extend {
drawer.clear(ColorRGBa.PINK)
sdf0.setShapes(shapes)
sdf1.setShapes(shapes.map {
it.transform(transform {
translate(1280 / 2.0, 720.0 / 2)
rotate(Vector3.Companion.UNIT_Z, seconds * 45.0 - 30.0)
translate(-1280 / 2.0, -720.0 / 2.0)
})
})
sdf0.apply(emptyArray(), df0)
sdf1.apply(emptyArray(), df1)
union.radius = 10.0 + min(mouse.position.y, 100.0)
union.apply(arrayOf(df0, df1), df0)
onion.radius = 20.0
onion.apply(df0, df0)
strokeFill.strokeWeight = 2.0
strokeFill.apply(df0, df0)
drawer.image(df0)
}
}
}
}