-
Notifications
You must be signed in to change notification settings - Fork 37
/
DemoShapeSDF05.kt
76 lines (62 loc) · 2.41 KB
/
DemoShapeSDF05.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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.fx.distort.Perturb
import org.openrndr.extra.gui.GUI
import org.openrndr.extra.jumpfill.ShapeSDF
import org.openrndr.extra.jumpfill.draw.SDFStrokeFill
import org.openrndr.extra.jumpfill.ops.SDFSmoothDifference
import org.openrndr.extra.svg.loadSVG
import org.openrndr.math.Vector2
import org.openrndr.shape.Circle
import kotlin.math.cos
import kotlin.math.sin
fun main() {
application {
configure {
width = 1280
height = 720
}
program {
val gui = GUI()
val sdf0 = ShapeSDF()
val sdf1 = ShapeSDF()
val df0 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val df1 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
val perturb = Perturb()
perturb.outputUV = true
val uvmap = colorBuffer(width, height, type = ColorType.FLOAT16)
val uvmap2 = colorBuffer(width, height, type = ColorType.FLOAT16)
val circleShapes = List(1) { Circle(width/2.0, height/2.0, 200.0).shape}
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
sdf0.setShapes(circleShapes)
sdf1.setShapes(shapes)
val difference = SDFSmoothDifference()
val strokeFill = SDFStrokeFill()
sdf0.useUV = true
gui.add(sdf0)
gui.add(perturb)
gui.add(strokeFill)
gui.add(difference)
extend(gui)
extend {
drawer.clear(ColorRGBa.PINK)
perturb.offset = Vector2(cos(seconds*0.2), sin(seconds*0.2))
perturb.outputUV = true
perturb.phase = seconds * 0.1
perturb.apply(uvmap, uvmap)
perturb.offset = Vector2.ZERO
perturb.outputUV = false
perturb.phase = seconds * 0.05
perturb.apply(uvmap, uvmap2)
sdf0.apply(uvmap2, df0)
sdf1.apply(uvmap2, df1)
difference.apply(arrayOf(df0, df1), df0)
strokeFill.apply(df0, df0)
drawer.image(df0)
}
}
}
}