From fe979f5a75834f95094ed2a88d23ae2eeb686ab9 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Sun, 26 Jul 2020 12:15:40 +0200 Subject: [PATCH] Bump to OPENRNDR 0.3.44-rc.6, add demos --- build.gradle | 2 +- .../src/demo/kotlin/DemoCatmullRom01.kt | 30 +++++++++++++++++++ .../src/demo/kotlin/DemoPointBatch01.kt | 22 ++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 openrndr-demos/src/demo/kotlin/DemoCatmullRom01.kt create mode 100644 openrndr-demos/src/demo/kotlin/DemoPointBatch01.kt diff --git a/build.gradle b/build.gradle index f08930bd..a91fbf8e 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.5" + openrndrVersion = openrndrUseSnapshot? "0.4.0-SNAPSHOT" : "0.3.44-rc.6" kotlinVersion = "1.3.72" spekVersion = "2.0.11" libfreenectVersion = "0.5.7-1.5.3" diff --git a/openrndr-demos/src/demo/kotlin/DemoCatmullRom01.kt b/openrndr-demos/src/demo/kotlin/DemoCatmullRom01.kt new file mode 100644 index 00000000..f448aef7 --- /dev/null +++ b/openrndr-demos/src/demo/kotlin/DemoCatmullRom01.kt @@ -0,0 +1,30 @@ +// Converting Catmull-Rom curves to Bezier + +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.math.CatmullRomChain2 +import org.openrndr.math.Polar +import org.openrndr.shape.ShapeContour +import org.openrndr.shape.toContour + +fun main() = application { + program { + val points = List(6) { Polar(it * 70.0, 100.0).cartesian + drawer.bounds.center } + val cmr = CatmullRomChain2(points, 1.0, loop = true) + val contour = ShapeContour.fromPoints(cmr.positions(200), true) + + extend { + drawer.run { + clear(ColorRGBa.WHITE) + fill = null + stroke = ColorRGBa.BLACK + contour(contour) + circles(points, 5.0) + + stroke = ColorRGBa.RED + contour(cmr.toContour()) + fill = ColorRGBa.BLACK + } + } + } +} diff --git a/openrndr-demos/src/demo/kotlin/DemoPointBatch01.kt b/openrndr-demos/src/demo/kotlin/DemoPointBatch01.kt new file mode 100644 index 00000000..3ad0e9a6 --- /dev/null +++ b/openrndr-demos/src/demo/kotlin/DemoPointBatch01.kt @@ -0,0 +1,22 @@ +// Drawing points using a stored batch + +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.draw.pointBatch + +fun main() = application { + program { + val storedBatch = drawer.pointBatch { + for (y in 10 until height step 20) { + for (x in 10 until width step 20) { + fill = ColorRGBa.PINK.shade(Math.random()) + point(x * 1.0, y * 1.0) + } + } + } + extend { + drawer.clear(ColorRGBa.GRAY) + drawer.points(storedBatch) + } + } +} \ No newline at end of file