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

@@ -9,10 +9,15 @@ import org.openrndr.draw.isolated
import org.openrndr.draw.renderTarget
import org.openrndr.math.Matrix44
class NoClear(val block: (() -> Unit)? = null): Extension {
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
if (renderTarget == null || renderTarget?.width != program.width || renderTarget?.height != program.height) {
@@ -29,7 +34,7 @@ class NoClear(val block: (() -> Unit)? = null): Extension {
renderTarget?.let {
drawer.withTarget(it) {
background(program.backgroundColor ?: ColorRGBa.TRANSPARENT)
block?.invoke()
backdrop?.invoke() // draw custom backdrop
}
}
}