-
Notifications
You must be signed in to change notification settings - Fork 37
/
DemoViewBox01.kt
66 lines (61 loc) · 2.02 KB
/
DemoViewBox01.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
import org.openrndr.application
import org.openrndr.draw.BufferMultisample
import org.openrndr.draw.DrawPrimitive
import org.openrndr.extensions.Screenshots
import org.openrndr.extra.camera.Camera2D
import org.openrndr.extra.camera.Orbital
import org.openrndr.extra.fx.Post
import org.openrndr.extra.fx.blur.ApproximateGaussianBlur
import org.openrndr.extra.meshgenerators.boxMesh
import org.openrndr.extra.viewbox.viewBox
import org.openrndr.shape.Rectangle
fun main() {
application {
configure {
width = 800
height = 800
}
program {
val vbx = viewBox(Rectangle(0.0, 0.0, 200.0, 800.0)) {
extend(Screenshots())
extend(Camera2D()).also {
shouldDraw = { it.hasChanged }
}
extend {
drawer.rectangle(20.0, 20.0, 100.0, 100.0)
}
}
val vbx2 = viewBox(Rectangle(200.0, 0.0, 200.0, 800.0)) {
extend(Post()) {
val blur = ApproximateGaussianBlur()
blur.sigma = 10.0
blur.window = 25
post { i, o ->
blur.apply(i, o)
}
}
extend(Camera2D())
extend {
drawer.rectangle(20.0, 20.0, 100.0, 100.0)
drawer.circle(mouse.position, 10.0)
}
}
val vbx3d = viewBox(Rectangle(400.0, 0.0, 400.0, 800.0), multisample = BufferMultisample.SampleCount(8)) {
extend(Orbital()).also {
this.shouldDraw = {
it.hasChanged
}
}
val cube = boxMesh()
extend {
drawer.vertexBuffer(cube, DrawPrimitive.TRIANGLES)
}
}
extend {
vbx.draw()
vbx2.draw()
vbx3d.draw()
}
}
}
}