Add configuration option for script host to oliveProgram
This commit is contained in:
BIN
orx-olive/images/DemoOlive01Kt.png
Normal file
BIN
orx-olive/images/DemoOlive01Kt.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
@@ -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
|
||||
|
||||
@@ -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<OliveProgram>(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()
|
||||
|
||||
Reference in New Issue
Block a user