[orx-property-watchers] Add imageChangedEvent parameter

This commit is contained in:
Edwin Jakobs
2023-03-20 14:13:26 +01:00
parent b3d11aa082
commit 8e3e4bddb0

View File

@@ -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<String>, imageTransform: (ColorBuffer) -> ColorBuffer = { it }) =
watchingProperty(pathProperty, cleaner = { it.destroy() }) {
fun watchingImagePath(
pathProperty: KProperty0<String>,
imageChangedEvent: Event<ColorBuffer>? = 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" }