From b32d32248e0bfd6e763991b14c9d7bf29063ed29 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 3 Oct 2026 22:37:16 +0530 Subject: Fix recording --- src/main/kotlin/phenax/utils/program.kt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/main/kotlin/phenax/utils') 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