-
Notifications
You must be signed in to change notification settings - Fork 37
/
DemoCompositor02.kt
51 lines (47 loc) · 1.56 KB
/
DemoCompositor02.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
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.BufferMultisample
import org.openrndr.extra.compositor.blend
import org.openrndr.extra.compositor.compose
import org.openrndr.extra.compositor.draw
import org.openrndr.extra.compositor.layer
import org.openrndr.extra.fx.blend.Normal
import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
/**
* Demonstration of using [BufferMultisample] on a per layer basis.
* Try changing which layer has multisampling applied and observe the results.
*/
fun main() = application {
System.setProperty("org.openrndr.gl3.debug", "true")
configure {
width = 800
height = 800
}
program {
val layers = compose {
layer(multisample = BufferMultisample.SampleCount(4)) {
draw {
drawer.translate(drawer.bounds.center)
drawer.rotate(seconds)
drawer.fill = ColorRGBa.PINK
drawer.rectangle(Rectangle.fromCenter(Vector2.ZERO, 200.0))
}
layer {
blend(Normal()) {
clip = true
}
draw {
drawer.rotate(seconds * -2)
drawer.fill = ColorRGBa.WHITE
drawer.rectangle(Rectangle.fromCenter(Vector2.ZERO, 200.0))
}
}
}
}
extend {
drawer.clear(ColorRGBa.WHITE)
layers.draw(drawer)
}
}
}