From dd070a968231fa36d29730b75070ab13d1f72ec9 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Thu, 30 Apr 2020 13:43:15 +0200 Subject: [PATCH] Add screenshot code to olive scriptless demo --- .../src/demo/kotlin/DemoOliveScriptless01.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/orx-olive/src/demo/kotlin/DemoOliveScriptless01.kt b/orx-olive/src/demo/kotlin/DemoOliveScriptless01.kt index fb2a098a..6716508f 100644 --- a/orx-olive/src/demo/kotlin/DemoOliveScriptless01.kt +++ b/orx-olive/src/demo/kotlin/DemoOliveScriptless01.kt @@ -1,6 +1,8 @@ +import org.openrndr.Extension import org.openrndr.Program import org.openrndr.application import org.openrndr.color.ColorRGBa +import org.openrndr.extensions.SingleScreenshot import org.openrndr.extra.olive.Olive import org.openrndr.math.IntVector2 @@ -13,6 +15,21 @@ fun main() { } program { extend(Olive()) { + // -- this block is for automation purposes only + if (System.getProperty("takeScreenshot") == "true") { + scriptLoaded.listen { + // -- this is a bit of hack, we need to push the screenshot extension in front of the olive one + fun Program.extendHead(extension: T, configure: T.() -> Unit): T { + extensions.add(0, extension) + extension.configure() + extension.setup(this) + return extension + } + extendHead(SingleScreenshot()) { + this.outputFile = System.getProperty("screenshotPath") + } + } + } script = "orx-olive/src/demo/kotlin/DemoOliveScriptless01.kt" program { extend {