feedback1-configurable-var

This commit is contained in:
CodeCox
2018-11-26 05:23:56 +00:00
parent ef684668a8
commit 1ce277bd41
2 changed files with 23 additions and 16 deletions

View File

@@ -20,33 +20,35 @@ fun main() = application {
}
```
#### Usage with a Lambda Expression Parameter
Optionally, the static backdrop may be initialised by passing a custom code block to the `NoClear()` function.
#### Usage with additional configuration
Optionally, a static `backdrop` may be setup by providing custom code.
- Example 1. Customising the backdrop with an image
```kotlin
val img = loadImage("file:data\\myImage.png")
val bgImage = {
extend(NoClear()) {
val img = loadImage("data\\backdrop.png")
backdrop = {
drawer.image(img, 0.0, 0.0, width * 1.0, height * 1.0)
}
extend(NoClear(bgImage))
}
```
- Example 2. Customising the backdrop with a checker-board pattern
```kotlin
val bgBoard = {
val xw = width / 8.0
val yh = height / 8.0
drawer.fill = ColorRGBa.RED
(0..7).forEach { row ->
(0..7).forEach { col ->
if ((row + col) % 2 == 0) {
drawer.rectangle(row * xw, col * yh, xw, yh)
extend(NoClear()) {
backdrop = {
val xw = width / 8.0
val yh = height / 8.0
drawer.fill = ColorRGBa.RED
(0..7).forEach { row ->
(0..7).forEach { col ->
if ((row + col) % 2 == 0) {
drawer.rectangle(row * xw, col * yh, xw, yh)
}
}
}
}
}
extend(NoClear(bgBoard))
```
NB! any submitted _lambda expression_ must be valid within the `renderTarget` context.