Files
orx/orx-jvm/orx-rabbit-control/src/demo/kotlin/DemoRabbitControlManualOverlay.kt
2021-06-22 11:08:07 +02:00

54 lines
1.4 KiB
Kotlin

import org.openrndr.KEY_HOME
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extensions.SingleScreenshot
import org.openrndr.extra.parameters.*
suspend fun main() = application {
configure {
width = 800
height = 800
}
program {
// -- this block is for automation purposes only
if (System.getProperty("takeScreenshot") == "true") {
extend(SingleScreenshot()) {
this.outputFile = System.getProperty("screenshotPath")
}
}
val rabbit = RabbitControlServer(showQRUntilClientConnects = false)
val settings = object {
@BooleanParameter("White on black")
var whiteOnBlack: Boolean = true
}
rabbit.add(settings)
extend(rabbit)
/**
* Example: only show the QR code when the [KEY_HOME] button is pressed
*/
keyboard.keyDown.listen {
when (it.key) {
KEY_HOME -> rabbit.showQRCode = true
}
}
keyboard.keyUp.listen {
when (it.key) {
KEY_HOME -> rabbit.showQRCode = false
}
}
extend {
drawer.clear(if (settings.whiteOnBlack) ColorRGBa.BLACK else ColorRGBa.WHITE)
drawer.fill = if (settings.whiteOnBlack) ColorRGBa.WHITE else ColorRGBa.BLACK
drawer.circle(drawer.bounds.center, 250.0)
}
}
}