diff --git a/orx-olive/images/DemoOlive01Kt.png b/orx-olive/images/DemoOlive01Kt.png new file mode 100644 index 00000000..e4a00494 Binary files /dev/null and b/orx-olive/images/DemoOlive01Kt.png differ diff --git a/orx-olive/src/demo/kotlin/DemoOliveScriptless01.kt b/orx-olive/src/demo/kotlin/DemoOliveScriptless01.kt index 8100a887..cd564617 100644 --- a/orx-olive/src/demo/kotlin/DemoOliveScriptless01.kt +++ b/orx-olive/src/demo/kotlin/DemoOliveScriptless01.kt @@ -2,6 +2,7 @@ import org.openrndr.Extension import org.openrndr.application import org.openrndr.color.ColorRGBa import org.openrndr.extensions.SingleScreenshot +import org.openrndr.extra.olive.OliveScriptHost import org.openrndr.extra.olive.oliveProgram import kotlin.math.cos @@ -11,7 +12,7 @@ fun main() { width = 1280 height = 720 } - oliveProgram { + oliveProgram(scriptHost = OliveScriptHost.JSR223) { extend { drawer.clear(ColorRGBa.GRAY) drawer.fill = ColorRGBa.WHITE diff --git a/orx-olive/src/main/kotlin/OliveProgram.kt b/orx-olive/src/main/kotlin/OliveProgram.kt index 45b02f88..06b00024 100644 --- a/orx-olive/src/main/kotlin/OliveProgram.kt +++ b/orx-olive/src/main/kotlin/OliveProgram.kt @@ -7,7 +7,7 @@ import java.nio.file.Files import java.nio.file.Paths import kotlin.streams.toList -open class OliveProgram(private val sourceLocation: String) : Program() { +open class OliveProgram(private val sourceLocation: String, private val scriptHost: OliveScriptHost) : Program() { val olive = extend(Olive(scriptMode = ScriptMode.OLIVE_PROGRAM)) { script = sourceLocation } @@ -19,7 +19,7 @@ fun stackRootClassName(thread: Thread = Thread.currentThread(), sanitize: Boolea return if (sanitize) rootClass.replace(Regex("Kt$"), "") else rootClass } -fun ApplicationBuilder.oliveProgram(init: OliveProgram.() -> Unit): OliveProgram { +fun ApplicationBuilder.oliveProgram(scriptHost: OliveScriptHost = OliveScriptHost.JSR223_REUSE, init: OliveProgram.() -> Unit): OliveProgram { val rootClassName = stackRootClassName(sanitize = true).split(".").last() var sourceLocation = "src/main/kotlin/$rootClassName.kt" @@ -33,7 +33,7 @@ fun ApplicationBuilder.oliveProgram(init: OliveProgram.() -> Unit): OliveProgram error("multiple source candidates found: $otherCandidates") } } - program = object : OliveProgram(sourceLocation) { + program = object : OliveProgram(sourceLocation, scriptHost) { override fun setup() { super.setup() init()