From 5fea79055d2c395a85f2ffb5a6e00bd29e057cd4 Mon Sep 17 00:00:00 2001 From: vechro Date: Mon, 16 May 2022 21:53:06 +0300 Subject: [PATCH] Add new compositor demo for multisampling --- .../src/demo/kotlin/DemoCompositor02.kt | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 orx-compositor/src/demo/kotlin/DemoCompositor02.kt diff --git a/orx-compositor/src/demo/kotlin/DemoCompositor02.kt b/orx-compositor/src/demo/kotlin/DemoCompositor02.kt new file mode 100644 index 000000000..c1e6dd32b --- /dev/null +++ b/orx-compositor/src/demo/kotlin/DemoCompositor02.kt @@ -0,0 +1,50 @@ +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 { + configure { + width = 800 + height = 800 + } + + program { + val layers = compose { + layer(BufferMultisample.SampleCount(16)) { + 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) + } + } +} \ No newline at end of file