From 677f821ca8a4495015c51bbb262fa7d84ad358d2 Mon Sep 17 00:00:00 2001 From: Abe Pazos Date: Wed, 20 May 2020 14:08:31 +0200 Subject: [PATCH] Improve demos for better screenshots, cleanup --- orx-gui/src/demo/kotlin/DemoOptions01.kt | 12 ++++++---- orx-gui/src/demo/kotlin/DemoSimple01.kt | 12 ++++++---- orx-gui/src/demo/kotlin/DemoXYParameter.kt | 9 +++++++ .../src/demo/kotlin/DemoShapeSDF02.kt | 6 +++-- .../src/demo/kotlin/DemoRabbitControl.kt | 12 ++++++---- .../kotlin/DemoRabbitControlManualOverlay.kt | 12 ++++++---- .../src/demo/kotlin/DemoRegularPolygon.kt | 24 ++++++++++++------- .../src/demo/kotlin/DemoRegularStar01.kt | 7 +++--- .../src/demo/kotlin/DemoRegularStar02.kt | 1 - orx-time-operators/src/demo/kotlin/DemoLFO.kt | 1 + 10 files changed, 61 insertions(+), 35 deletions(-) diff --git a/orx-gui/src/demo/kotlin/DemoOptions01.kt b/orx-gui/src/demo/kotlin/DemoOptions01.kt index f4e2db3d..53ead58c 100644 --- a/orx-gui/src/demo/kotlin/DemoOptions01.kt +++ b/orx-gui/src/demo/kotlin/DemoOptions01.kt @@ -16,6 +16,13 @@ enum class BackgroundColors { fun main() = application { program { + // -- this block is for automation purposes only + if (System.getProperty("takeScreenshot") == "true") { + extend(SingleScreenshot()) { + this.outputFile = System.getProperty("screenshotPath") + } + } + val gui = GUI() gui.compartmentsCollapsedByDefault = false val settings = @Description("Settings") object { @@ -24,11 +31,6 @@ fun main() = application { } gui.add(settings) - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } extend(gui) extend { when(settings.option) { diff --git a/orx-gui/src/demo/kotlin/DemoSimple01.kt b/orx-gui/src/demo/kotlin/DemoSimple01.kt index 68155873..4be8420d 100644 --- a/orx-gui/src/demo/kotlin/DemoSimple01.kt +++ b/orx-gui/src/demo/kotlin/DemoSimple01.kt @@ -11,6 +11,13 @@ import org.openrndr.shape.Circle */ fun main() = application { program { + // -- this block is for automation purposes only + if (System.getProperty("takeScreenshot") == "true") { + extend(SingleScreenshot()) { + this.outputFile = System.getProperty("screenshotPath") + } + } + val gui = GUI() gui.compartmentsCollapsedByDefault = false @@ -28,11 +35,6 @@ fun main() = application { var radii = mutableListOf(5.0, 6.0, 8.0, 14.0, 20.0, 30.0) } gui.add(settings) - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } extend(gui) extend { drawer.fill = settings.color diff --git a/orx-gui/src/demo/kotlin/DemoXYParameter.kt b/orx-gui/src/demo/kotlin/DemoXYParameter.kt index ffc80519..1300b793 100644 --- a/orx-gui/src/demo/kotlin/DemoXYParameter.kt +++ b/orx-gui/src/demo/kotlin/DemoXYParameter.kt @@ -1,4 +1,5 @@ import org.openrndr.application +import org.openrndr.extensions.SingleScreenshot import org.openrndr.extra.gui.GUI import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.XYParameter @@ -11,7 +12,15 @@ fun main() = application { } program { + // -- this block is for automation purposes only + if (System.getProperty("takeScreenshot") == "true") { + extend(SingleScreenshot()) { + this.outputFile = System.getProperty("screenshotPath") + } + } + val gui = GUI() + gui.compartmentsCollapsedByDefault = false val settings = @Description("Settings") object { @XYParameter("Position", 0.0, 800.0, 0.0, 800.0, diff --git a/orx-jumpflood/src/demo/kotlin/DemoShapeSDF02.kt b/orx-jumpflood/src/demo/kotlin/DemoShapeSDF02.kt index 68a66963..94141646 100644 --- a/orx-jumpflood/src/demo/kotlin/DemoShapeSDF02.kt +++ b/orx-jumpflood/src/demo/kotlin/DemoShapeSDF02.kt @@ -10,6 +10,7 @@ import org.openrndr.extra.jumpfill.ops.* import org.openrndr.math.Vector3 import org.openrndr.math.transforms.transform import org.openrndr.svg.loadSVG +import kotlin.math.min fun main() { application { @@ -32,6 +33,7 @@ fun main() { val strokeFill = SDFStrokeFill() + // -- this block is for automation purposes only if (System.getProperty("takeScreenshot") == "true") { extend(SingleScreenshot()) { this.outputFile = System.getProperty("screenshotPath") @@ -50,14 +52,14 @@ fun main() { sdf1.setShapes(shapes.mapIndexed { index, it -> it.transform(transform { translate(1280 / 2.0, 720.0 / 2) - rotate(Vector3.Companion.UNIT_Z, seconds * 45.0) + rotate(Vector3.Companion.UNIT_Z, seconds * 45.0 - 30.0) translate(-1280 / 2.0, -720.0 / 2.0) }) }) sdf0.apply(emptyArray(), df0) sdf1.apply(emptyArray(), df1) - union.radius = mouse.position.y + union.radius = 10.0 + min(mouse.position.y, 100.0) union.apply(arrayOf(df0, df1), df0) onion.radius = 20.0 onion.apply(df0, df0) diff --git a/orx-rabbit-control/src/demo/kotlin/DemoRabbitControl.kt b/orx-rabbit-control/src/demo/kotlin/DemoRabbitControl.kt index 7abb406a..e45170ab 100644 --- a/orx-rabbit-control/src/demo/kotlin/DemoRabbitControl.kt +++ b/orx-rabbit-control/src/demo/kotlin/DemoRabbitControl.kt @@ -15,6 +15,13 @@ fun main() = application { } program { + // -- this block is for automation purposes only + if (System.getProperty("takeScreenshot") == "true") { + extend(SingleScreenshot()) { + this.outputFile = System.getProperty("screenshotPath") + } + } + val rabbit = RabbitControlServer() val font= loadFont("orx-rabbit-control/src/demo/resources/fonts/Roboto-Regular.ttf", 20.0) val settings = object { @@ -49,11 +56,6 @@ fun main() = application { } rabbit.add(settings) - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } extend(rabbit) extend { drawer.clear(if (settings.b) ColorRGBa.BLUE else ColorRGBa.BLACK) diff --git a/orx-rabbit-control/src/demo/kotlin/DemoRabbitControlManualOverlay.kt b/orx-rabbit-control/src/demo/kotlin/DemoRabbitControlManualOverlay.kt index 405ec0fd..6bc65447 100644 --- a/orx-rabbit-control/src/demo/kotlin/DemoRabbitControlManualOverlay.kt +++ b/orx-rabbit-control/src/demo/kotlin/DemoRabbitControlManualOverlay.kt @@ -12,6 +12,13 @@ fun main() = application { } program { + // -- this block is for automation purposes only + if (System.getProperty("takeScreenshot") == "true") { + extend(SingleScreenshot()) { + this.outputFile = System.getProperty("screenshotPath") + } + } + val rabbit = RabbitControlServer(showQRUntilClientConnects = false) val settings = object { @@ -20,11 +27,6 @@ fun main() = application { } rabbit.add(settings) - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } extend(rabbit) /** diff --git a/orx-shapes/src/demo/kotlin/DemoRegularPolygon.kt b/orx-shapes/src/demo/kotlin/DemoRegularPolygon.kt index 7570bed4..828c1676 100644 --- a/orx-shapes/src/demo/kotlin/DemoRegularPolygon.kt +++ b/orx-shapes/src/demo/kotlin/DemoRegularPolygon.kt @@ -1,11 +1,10 @@ import org.openrndr.application import org.openrndr.color.ColorRGBa +import org.openrndr.draw.isolated import org.openrndr.extensions.SingleScreenshot -import org.openrndr.extra.shapes.RoundedRectangle import org.openrndr.extra.shapes.regularPolygon -import org.openrndr.extra.shapes.regularStar +import org.openrndr.math.map import kotlin.math.cos -import kotlin.math.sin fun main() = application { program { @@ -18,12 +17,21 @@ fun main() = application { extend { drawer.fill = ColorRGBa.PINK drawer.stroke = ColorRGBa.WHITE - val radius0 = cos(seconds) * 50.0 + 130.0 - val star = regularPolygon(6, radius = radius0) - drawer.translate(width/2.0, height / 2.0) - drawer.rotate(seconds * 45.0) - drawer.contour(star) + for (sides in 0 until 8) { + val radius0 = cos(seconds + sides) * 20.0 + 40.0 + val star = regularPolygon(sides + 3, radius = radius0) + + drawer.isolated { + translate( + (sides % 4.0).map(0.0, 3.0, + width * 0.2, width * 0.8), + (sides / 4).toDouble().map(0.0, 1.0, + height * 0.3, height * 0.7)) + rotate(seconds * 45.0) + contour(star) + } + } } } } \ No newline at end of file diff --git a/orx-shapes/src/demo/kotlin/DemoRegularStar01.kt b/orx-shapes/src/demo/kotlin/DemoRegularStar01.kt index 532ac043..138164b8 100644 --- a/orx-shapes/src/demo/kotlin/DemoRegularStar01.kt +++ b/orx-shapes/src/demo/kotlin/DemoRegularStar01.kt @@ -1,7 +1,6 @@ import org.openrndr.application import org.openrndr.color.ColorRGBa import org.openrndr.extensions.SingleScreenshot -import org.openrndr.extra.shapes.RoundedRectangle import org.openrndr.extra.shapes.regularStar import kotlin.math.cos import kotlin.math.sin @@ -17,12 +16,12 @@ fun main() = application { extend { drawer.fill = ColorRGBa.PINK drawer.stroke = ColorRGBa.WHITE - val radius0 = cos(seconds) * 50.0 + 130.0 - val radius1 = sin(seconds) * 50.0 + 130.0 + val radius0 = cos(seconds + 2) * 50.0 + 130.0 + val radius1 = sin(seconds + 2) * 50.0 + 130.0 val star = regularStar(5, radius0, radius1) - drawer.translate(width/2.0, height / 2.0) + drawer.translate(width / 2.0, height / 2.0) drawer.rotate(seconds * 45.0) drawer.contour(star) } diff --git a/orx-shapes/src/demo/kotlin/DemoRegularStar02.kt b/orx-shapes/src/demo/kotlin/DemoRegularStar02.kt index 4acd670d..acd60890 100644 --- a/orx-shapes/src/demo/kotlin/DemoRegularStar02.kt +++ b/orx-shapes/src/demo/kotlin/DemoRegularStar02.kt @@ -1,7 +1,6 @@ import org.openrndr.application import org.openrndr.color.ColorRGBa import org.openrndr.extensions.SingleScreenshot -import org.openrndr.extra.shapes.RoundedRectangle import org.openrndr.extra.shapes.regularStar import org.openrndr.math.Vector2 import kotlin.math.cos diff --git a/orx-time-operators/src/demo/kotlin/DemoLFO.kt b/orx-time-operators/src/demo/kotlin/DemoLFO.kt index 8dcd00af..79e22b84 100644 --- a/orx-time-operators/src/demo/kotlin/DemoLFO.kt +++ b/orx-time-operators/src/demo/kotlin/DemoLFO.kt @@ -13,6 +13,7 @@ fun main() { val rotation = LFO(LFOWave.Sine) if (System.getProperty("takeScreenshot") == "true") { extend(SingleScreenshot()) { + this.delayFrames = 10 this.outputFile = System.getProperty("screenshotPath") } }