[orx-property-watchers] Add imageChangedEvent parameter
This commit is contained in:
@@ -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" }
|
||||
|
||||
Reference in New Issue
Block a user