From 8e3e4bddb06a0d6aac3f3a45dbabf325ab1aadae Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Mon, 20 Mar 2023 14:13:26 +0100 Subject: [PATCH] [orx-property-watchers] Add imageChangedEvent parameter --- orx-property-watchers/src/jvmMain/kotlin/ImagePath.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/orx-property-watchers/src/jvmMain/kotlin/ImagePath.kt b/orx-property-watchers/src/jvmMain/kotlin/ImagePath.kt index c7d53d3e..2b064a73 100644 --- a/orx-property-watchers/src/jvmMain/kotlin/ImagePath.kt +++ b/orx-property-watchers/src/jvmMain/kotlin/ImagePath.kt @@ -2,6 +2,7 @@ package org.openrndr.extra.propertywatchers import org.openrndr.draw.ColorBuffer import org.openrndr.draw.loadImage +import org.openrndr.events.Event import java.io.File import kotlin.reflect.KProperty0 @@ -11,8 +12,12 @@ import kotlin.reflect.KProperty0 * @param imageTransform an optional image transform function * @since 0.4.3 */ -fun watchingImagePath(pathProperty: KProperty0, imageTransform: (ColorBuffer) -> ColorBuffer = { it }) = - watchingProperty(pathProperty, cleaner = { it.destroy() }) { +fun watchingImagePath( + pathProperty: KProperty0, + imageChangedEvent: Event? = null, + imageTransform: (ColorBuffer) -> ColorBuffer = { it } +) = + watchingProperty(pathProperty, imageChangedEvent, cleaner = { it.destroy() }) { val file = File(it) require(file.exists()) { "$it does not exist" } require(file.isFile) { "$it is not a file" }