forked from openrndr/orx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DemoImagePathWatcher01.kt
33 lines (31 loc) · 1.07 KB
/
DemoImagePathWatcher01.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.grayscale
import org.openrndr.draw.tint
import org.openrndr.drawImage
import org.openrndr.extra.propertywatchers.watchingImagePath
import org.openrndr.extra.propertywatchers.watchingProperty
fun main() {
application {
program {
val state = object {
var path = "demo-data/images/image-001.png"
val image by watchingImagePath(::path) {
drawImage(it.width, it.height) {
drawer.drawStyle.colorMatrix = grayscale()
drawer.image(it)
}
}
val redImage by watchingProperty(::image, cleaner = { it.destroy() }) {
drawImage(it.width, it.height) {
drawer.drawStyle.colorMatrix = tint(ColorRGBa.RED)
drawer.image(it)
}
}
}
extend {
drawer.image(state.redImage)
}
}
}
}