[openrndr-demos] Add DemoCompositionDrawer01

This commit is contained in:
Edwin Jakobs
2020-07-19 23:53:04 +02:00
parent 960b49b78f
commit ed48736985
2 changed files with 38 additions and 0 deletions

View File

@@ -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")

View File

@@ -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))
}
}
}
}