openrndr / org.openrndr / Program

Program

open class Program (source)

The Program class, this is where most user implementations start

Types

CharacterEvent

class CharacterEvent

Clipboard

inner class Clipboard

Window

Simplified window interface

inner class Window

Constructors

<init>

The Program class, this is where most user implementations start

Program()

Properties

application

lateinit var application: Application

backgroundColor

background color that is used to clear the background every frame

var backgroundColor: ColorRGBa?

clipboard

val clipboard: Clipboard

clock

clock function. defaults to returning the application time.

var clock: () -> Double

deltaTime

The elapsed time since the last draw loop

val deltaTime: Double

dispatcher

val dispatcher: Dispatcher

drawer

lateinit var drawer: Drawer

driver

lateinit var driver: Driver

ended

program ended event

var ended: Event<ProgramEvent>

extensions

list of installed extensions

val extensions: MutableList<Extension>

frameCount

var frameCount: Int

height

var height: Int

keyboard

val keyboard: Keyboard

mouse

val mouse: Mouse

name

var name: String

seconds

The number of seconds since program start, or the time from a custom clock. value is updated at the beginning of the frame only.

val seconds: Double

width

var width: Int

window

val window: Window

Functions

draw

This is the user facing draw call. It should be overridden by the user.

open fun draw(): Unit

drawImpl

This is the draw call that is called by Application. It takes care of handling extensions.

fun drawImpl(): Unit

extend

install an Extension

fun <T : Extension> extend(extension: T): T

install an Extension and configure it

fun <T : Extension> extend(extension: T, configure: T.() -> Unit): T

install an extension function for the given ExtensionStage

fun extend(stage: ExtensionStage = ExtensionStage.BEFORE_DRAW, userDraw: Program.() -> Unit): Unit

setup

This is ran exactly once before the first call to draw()

open fun setup(): Unit

Extension Functions

launch

launch a coroutine in the Program context

fun Program.launch(context: CoroutineContext = dispatcher, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> Unit): Job

loadFont

fun Program.loadFont(fileOrUrl: String, size: Double, characterSet: Set<Char> = defaultFontmapCharacterSet, contentScale: Double = this.drawer.context.contentScale): FontImageMap

namedTimestamp

Use to automatically generate a String like path/basename-date.extension when saving files like videos, images, json, etc. basename defaults to the current program or window name. Used by ScreenRecorder, Screenshots and available to the user.

fun Program.namedTimestamp(extension: String = "", folder: String? = null): String

writer

fun Program.writer(f: Writer.() -> Unit): Unit