From ed48736985874e65d2e7ee16fb907780dac5d04e Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Sun, 19 Jul 2020 23:53:04 +0200 Subject: [PATCH] [openrndr-demos] Add DemoCompositionDrawer01 --- openrndr-demos/build.gradle | 1 + .../demo/kotlin/DemoCompositionDrawer01.kt | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 openrndr-demos/src/demo/kotlin/DemoCompositionDrawer01.kt diff --git a/openrndr-demos/build.gradle b/openrndr-demos/build.gradle index 1a191199..827bff2d 100644 --- a/openrndr-demos/build.gradle +++ b/openrndr-demos/build.gradle @@ -19,6 +19,7 @@ dependencies { demoImplementation("org.openrndr:openrndr-core:$openrndrVersion") demoImplementation("org.openrndr:openrndr-extensions:$openrndrVersion") demoImplementation("org.openrndr:openrndr-ffmpeg:$openrndrVersion") + demoImplementation("org.openrndr:openrndr-svg:$openrndrVersion") demoRuntimeOnly("org.openrndr:openrndr-ffmpeg-natives-$openrndrOS:$openrndrVersion") demoRuntimeOnly("org.openrndr:openrndr-gl3:$openrndrVersion") demoRuntimeOnly("org.openrndr:openrndr-gl3-natives-$openrndrOS:$openrndrVersion") diff --git a/openrndr-demos/src/demo/kotlin/DemoCompositionDrawer01.kt b/openrndr-demos/src/demo/kotlin/DemoCompositionDrawer01.kt new file mode 100644 index 00000000..781244c9 --- /dev/null +++ b/openrndr-demos/src/demo/kotlin/DemoCompositionDrawer01.kt @@ -0,0 +1,37 @@ +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.math.Vector2 +import org.openrndr.shape.CompositionDrawer +import org.openrndr.svg.writeSVG + +fun main() { + application { + program { + + extend { + + drawer.clear(ColorRGBa.WHITE) + + val cd = CompositionDrawer() + val layer = cd.group { + fill = ColorRGBa.PINK + stroke = ColorRGBa.BLACK + strokeWeight = 10.0 + circle(Vector2(width/2.0, height/2.0), 100.0) + circle(Vector2(200.0, 200.0), 50.0) + } + // demonstrating how to set custom attributes on the CompositionNode + // these are stored in SVG + layer.id = "Layer_2" + layer.attributes["openrndr:custom"] = "5" + + // draw the composition to the screen + drawer.composition(cd.composition) + + // print the svg to the console + println(writeSVG(cd.composition)) + + } + } + } +} \ No newline at end of file