Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -14,7 +14,7 @@ A growing library of assorted data structures, algorithms and utilities.
|
||||
- [`orx-obj-loader`](orx-obj-loader/README.md), simple Wavefront .obj mesh loader
|
||||
|
||||
## Usage
|
||||
ORX 0.0.14 is built against OPENRNDR 0.3.30-rc1, make sure you use this version in your project. Because OPENRNDR's API is pre 1.0 it tends to change from time to time.
|
||||
ORX 0.0.14 is built against OPENRNDR 0.3.30-rc2, make sure you use this version in your project. Because OPENRNDR's API is pre 1.0 it tends to change from time to time.
|
||||
|
||||
The easiest way to add ORX to your project is through the use of Jitpack. [Jitpack](http://jitpack.io) is a service that pulls Gradle based libraries from Github, builds them and serves the jar files.
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ repositories {
|
||||
}
|
||||
|
||||
ext {
|
||||
openrndrVersion = "0.3.30-rc1"
|
||||
openrndrVersion = "0.3.30-rc2"
|
||||
}
|
||||
|
||||
subprojects {
|
||||
|
||||
@@ -5,17 +5,50 @@ OPENRNDR does not support natively.
|
||||
|
||||
#### Usage
|
||||
|
||||
```
|
||||
class NoClearProgram: Program() {
|
||||
|
||||
override fun setup() {
|
||||
```kotlin
|
||||
fun main() = application {
|
||||
configure {
|
||||
title = "NoClearProgram"
|
||||
}
|
||||
program {
|
||||
backgroundColor = ColorRGBa.PINK
|
||||
extend(NoClear())
|
||||
}
|
||||
|
||||
override fun draw() {
|
||||
drawer.circle(Math.cos(seconds) * width / 2.0 + width / 2.0, Math.sin(seconds * 0.24) * height / 2.0 + height / 2.0, 20.0)
|
||||
extend {
|
||||
drawer.circle(Math.cos(seconds) * width / 2.0 + width / 2.0, Math.sin(seconds * 0.24) * height / 2.0 + height / 2.0, 20.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
#### Usage with additional configuration
|
||||
Optionally, a static `backdrop` may be setup by providing custom code.
|
||||
|
||||
- Example 1. Customising the backdrop with an image
|
||||
```kotlin
|
||||
extend(NoClear()) {
|
||||
val img = loadImage("data\\backdrop.png")
|
||||
backdrop = {
|
||||
drawer.image(img, 0.0, 0.0, width * 1.0, height * 1.0)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- Example 2. Customising the backdrop with a checker-board pattern
|
||||
```kotlin
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
NB! any submitted _lambda expression_ must be valid within the `renderTarget` context.
|
||||
@@ -13,6 +13,10 @@ class NoClear : Extension {
|
||||
override var enabled: Boolean = true
|
||||
private var renderTarget: RenderTarget? = null
|
||||
|
||||
/**
|
||||
* code-block to draw an optional custom backdrop
|
||||
*/
|
||||
var backdrop: (() -> Unit)? = null
|
||||
|
||||
override fun beforeDraw(drawer: Drawer, program: Program) {
|
||||
if (program.width > 0 && program.height > 0) { // only if the window is not minimised
|
||||
@@ -30,6 +34,7 @@ class NoClear : Extension {
|
||||
renderTarget?.let {
|
||||
drawer.withTarget(it) {
|
||||
background(program.backgroundColor ?: ColorRGBa.TRANSPARENT)
|
||||
backdrop?.invoke() // draw custom backdrop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user