Files
orx/orx-timer/src/demo/kotlin/DemoRepeat02.kt
2025-11-22 19:08:30 +01:00

29 lines
832 B
Kotlin

import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.events.Event
import org.openrndr.extra.timer.repeat
/**
* This demonstrates how to combine `repeat {}` with a postponed event to trigger drawing.
*/
fun main() = application {
program {
val event = Event<Any?>()
event.postpone = true
event.listen {
drawer.circle(width / 2.0, height / 2.0, 200.0)
}
repeat(2.0) {
// -- we can not draw here, so we relay the repeat signal to the event
event.trigger(null)
}
extend {
drawer.clear(ColorRGBa.PINK)
// -- by explicitly calling deliver we know that the drawing code in the listener will be
// -- executed exactly here
event.deliver()
}
}
}