[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.ColorBuffer
|
||||||
import org.openrndr.draw.loadImage
|
import org.openrndr.draw.loadImage
|
||||||
|
import org.openrndr.events.Event
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.reflect.KProperty0
|
import kotlin.reflect.KProperty0
|
||||||
|
|
||||||
@@ -11,8 +12,12 @@ import kotlin.reflect.KProperty0
|
|||||||
* @param imageTransform an optional image transform function
|
* @param imageTransform an optional image transform function
|
||||||
* @since 0.4.3
|
* @since 0.4.3
|
||||||
*/
|
*/
|
||||||
fun watchingImagePath(pathProperty: KProperty0<String>, imageTransform: (ColorBuffer) -> ColorBuffer = { it }) =
|
fun watchingImagePath(
|
||||||
watchingProperty(pathProperty, cleaner = { it.destroy() }) {
|
pathProperty: KProperty0<String>,
|
||||||
|
imageChangedEvent: Event<ColorBuffer>? = null,
|
||||||
|
imageTransform: (ColorBuffer) -> ColorBuffer = { it }
|
||||||
|
) =
|
||||||
|
watchingProperty(pathProperty, imageChangedEvent, cleaner = { it.destroy() }) {
|
||||||
val file = File(it)
|
val file = File(it)
|
||||||
require(file.exists()) { "$it does not exist" }
|
require(file.exists()) { "$it does not exist" }
|
||||||
require(file.isFile) { "$it is not a file" }
|
require(file.isFile) { "$it is not a file" }
|
||||||
|
|||||||
Reference in New Issue
Block a user