diff --git a/build.gradle b/build.gradle index aa23836e..f08930bd 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ buildscript { apply plugin: 'org.jetbrains.dokka' project.ext { - openrndrVersion = openrndrUseSnapshot? "0.4.0-SNAPSHOT" : "0.3.44-rc.4" + openrndrVersion = openrndrUseSnapshot? "0.4.0-SNAPSHOT" : "0.3.44-rc.5" kotlinVersion = "1.3.72" spekVersion = "2.0.11" libfreenectVersion = "0.5.7-1.5.3" diff --git a/openrndr-demos/src/demo/kotlin/DemoCompositionDrawer01.kt b/openrndr-demos/src/demo/kotlin/DemoCompositionDrawer01.kt index 781244c9..3935d82e 100644 --- a/openrndr-demos/src/demo/kotlin/DemoCompositionDrawer01.kt +++ b/openrndr-demos/src/demo/kotlin/DemoCompositionDrawer01.kt @@ -1,36 +1,36 @@ import org.openrndr.application import org.openrndr.color.ColorRGBa import org.openrndr.math.Vector2 -import org.openrndr.shape.CompositionDrawer +import org.openrndr.shape.drawComposition +import org.openrndr.svg.svgNamespaceInkscape +import org.openrndr.svg.toSVG 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) + val composition = drawComposition { + val layer = 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["inkscape:label"] = "Layer 1" + layer.attributes["inkscape:groupmode"] = "layer" } - // 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) + drawer.composition(composition) // print the svg to the console - println(writeSVG(cd.composition)) - + println(composition.toSVG(namespaces = listOf(svgNamespaceInkscape))) } } } diff --git a/openrndr-demos/src/demo/kotlin/DemoVolumeTexture01.kt b/openrndr-demos/src/demo/kotlin/DemoVolumeTexture01.kt index 8072df89..fbb5e383 100644 --- a/openrndr-demos/src/demo/kotlin/DemoVolumeTexture01.kt +++ b/openrndr-demos/src/demo/kotlin/DemoVolumeTexture01.kt @@ -3,14 +3,8 @@ import org.openrndr.color.ColorRGBa import org.openrndr.draw.* import org.openrndr.extensions.Screenshots - fun main() = application { program { - - val screenshots = extend(Screenshots()) { - - } - val volumeTexture = VolumeTexture.create(128,128,32) val rt = renderTarget(128, 128) { volumeTexture(volumeTexture, 0) @@ -18,9 +12,6 @@ fun main() = application { val cb = colorBuffer(128, 128) extend { - - screenshots.afterScreenshot - drawer.isolatedWithTarget(rt) { drawer.ortho(rt) drawer.clear(ColorRGBa.PINK) @@ -28,6 +19,5 @@ fun main() = application { volumeTexture.copyTo(cb, 0) drawer.image(cb) } - } } \ No newline at end of file diff --git a/openrndr-demos/src/demo/kotlin/DrawerRectangleBatch01.kt b/openrndr-demos/src/demo/kotlin/DrawerRectangleBatch01.kt new file mode 100644 index 00000000..b9f69e09 --- /dev/null +++ b/openrndr-demos/src/demo/kotlin/DrawerRectangleBatch01.kt @@ -0,0 +1,16 @@ +// A single rectangle + +import org.openrndr.application +import org.openrndr.color.ColorRGBa + +fun main() = application { + program { + extend { + drawer.clear(ColorRGBa.GRAY) + drawer.fill = ColorRGBa.PINK + drawer.stroke = ColorRGBa.WHITE + drawer.strokeWeight = 2.0 + drawer.rectangle(100.0, 100.0, 50.0, 50.0) + } + } +} \ No newline at end of file diff --git a/openrndr-demos/src/demo/kotlin/DrawerRectangleBatch02.kt b/openrndr-demos/src/demo/kotlin/DrawerRectangleBatch02.kt new file mode 100644 index 00000000..6bea140a --- /dev/null +++ b/openrndr-demos/src/demo/kotlin/DrawerRectangleBatch02.kt @@ -0,0 +1,29 @@ +// Stored rectangle batches +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.draw.rectangleBatch + +fun main() = application { + program { + val batch = drawer.rectangleBatch { + fill = ColorRGBa.PINK + stroke = ColorRGBa.WHITE + for (i in 0 until 1000) { + strokeWeight = Math.random() * 5.0 + 1.0 + val rwidth = Math.random() * 40.0 + 4.0 + val rheight = Math.random() * 40.0 + 4.0 + val x = Math.random() * width + val y = Math.random() * height + rectangle(x, y, rwidth, rheight, Math.random() * 360.0) + } + } + + extend { + drawer.clear(ColorRGBa.GRAY) + drawer.fill = ColorRGBa.PINK + drawer.stroke = ColorRGBa.WHITE + drawer.strokeWeight = 2.0 + drawer.rectangles(batch) + } + } +} \ No newline at end of file diff --git a/openrndr-demos/src/demo/kotlin/DrawerRectangleBatch03.kt b/openrndr-demos/src/demo/kotlin/DrawerRectangleBatch03.kt new file mode 100644 index 00000000..e88db2c3 --- /dev/null +++ b/openrndr-demos/src/demo/kotlin/DrawerRectangleBatch03.kt @@ -0,0 +1,23 @@ +// Dynamic rectangle batches + +import org.openrndr.application +import org.openrndr.color.ColorRGBa + +fun main() = application { + program { + extend { + drawer.clear(ColorRGBa.GRAY) + drawer.fill = ColorRGBa.PINK + drawer.stroke = ColorRGBa.WHITE + drawer.strokeWeight = 2.0 + drawer.rectangles { + for (y in 0 until height/20) { + for (x in 0 until width/20) { + rectangle(x * 20.0, y * 20.0, 10.0, 15.0, (x + y) * 10.0 + seconds*90.0) + + } + } + } + } + } +} \ No newline at end of file