diff options
Diffstat (limited to 'src/main/kotlin/phenax/utils')
| -rw-r--r-- | src/main/kotlin/phenax/utils/program.kt | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/main/kotlin/phenax/utils/program.kt b/src/main/kotlin/phenax/utils/program.kt index cfbe9c9..fdb6197 100644 --- a/src/main/kotlin/phenax/utils/program.kt +++ b/src/main/kotlin/phenax/utils/program.kt @@ -4,23 +4,22 @@ import java.io.File import kotlin.properties.ReadOnlyProperty import org.openrndr.ApplicationBuilder import org.openrndr.Program -import org.openrndr.draw.* import org.openrndr.color.* +import org.openrndr.draw.* import org.openrndr.extra.filewatcher.watchingFile import org.openrndr.extra.olive.oliveProgram as oliveProgramOriginal -fun Int.seconds(): Int = this * 1000 - -fun Int.minutes(): Int = this.seconds() * 60 +fun Number.seconds(): Number = this -fun recordDuration(millis: Int) { - System.setProperty("phenax.record.frameCount", (60 * millis / 1000).toInt().toString()) +fun recordDuration(millis: Number) { + System.setProperty("phenax.record.recordDuration", millis.toDouble().toString()) } -fun recordDuration(): Int? = System.getProperty("phenax.record.frameCount")?.toIntOrNull() +fun recordDuration(): Double = System.getProperty("phenax.record.recordDuration")?.toDoubleOrNull() ?: 5000.0 val recordingEnabled: Boolean by lazy { System.getenv("PHENAX_RECORD") != null } val screenshotEnabled: Boolean by lazy { System.getenv("PHENAX_SCREENSHOT") != null } +val captureEnabled: Boolean by lazy { recordingEnabled || screenshotEnabled } // fun classDir(): String = // "src/main/kotlin/${stackRootClassName(sanitize = @@ -31,7 +30,7 @@ val screenshotEnabled: Boolean by lazy { System.getenv("PHENAX_SCREENSHOT") != n // Have to keep the same name (oliveProgram) to get update on save to work fun ApplicationBuilder.oliveProgram(init: Program.() -> Unit) { - if (recordingEnabled || screenshotEnabled) { + if (captureEnabled) { program(init) } else { // TODO: Make watching shader files work @@ -89,7 +88,7 @@ fun Program.liveComputeShader(name: String): ReadOnlyProperty<Any?, ComputeShade var cs: ComputeShader = ComputeShader.fromCode(shaderCode, name) - if (!recordingEnabled || screenshotEnabled) { + if (!captureEnabled) { var lastCompiledCode: String = shaderCode program.extend { |
