Skip to content

Latest commit

 

History

History

orx-no-clear

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

orx-no-clear

Provides the classical "draw-without-clearing-the-screen" functionality.

Usage

fun main() = application {
    configure {
        title = "NoClearProgram"
    }
    program {
        backgroundColor = ColorRGBa.PINK
        extend(NoClear())
        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
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
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.

Demos

DemoNoClear

source code

DemoNoClearKt