ProgramImplementation

open class ProgramImplementation(val suspend: Boolean = false) : Program(source)

The Program class, this is where most user implementations start.

Constructors

Link copied to clipboard
constructor(suspend: Boolean = false)

Types

Link copied to clipboard
Link copied to clipboard
inner class Window : Window

Simplified window interface

Properties

Link copied to clipboard
open lateinit override var application: Application
Link copied to clipboard
open override var assetMetadata: () -> AssetMetadata
Link copied to clipboard
Link copied to clipboard
open override var backgroundColor: ColorRGBa?

background color that is used to clear the background every frame

Link copied to clipboard
Link copied to clipboard
open override var clock: () -> Double

clock function. defaults to returning the application time.

Link copied to clipboard

The elapsed time since the last draw loop

Link copied to clipboard
open override val dispatcher: Dispatcher
Link copied to clipboard
open lateinit override var drawer: Drawer
Link copied to clipboard
open lateinit override var driver: Driver
Link copied to clipboard
open override var ended: Event<ProgramEvent>

program ended event

Link copied to clipboard
open override val extensions: MutableList<Extension>

list of installed extensions

Link copied to clipboard
open override var frameCount: Int
Link copied to clipboard
open override var height: Int
Link copied to clipboard
open override var isNested: Boolean

This is checked at runtime to disallow nesting extend blocks.

Link copied to clipboard
open override val keyboard: Keyboard
Link copied to clipboard
open override val mouse: ApplicationMouse
Link copied to clipboard
open override var name: String
Link copied to clipboard
open override val pointers: Pointers
Link copied to clipboard
Link copied to clipboard
open override val program: Program
Link copied to clipboard
Link copied to clipboard
open override val seconds: Double

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

Link copied to clipboard
val suspend: Boolean = false
Link copied to clipboard
open override var userProperties: MutableMap<String, Any>

A map that can be used to store arbitrary data, including functions

Link copied to clipboard
open override var width: Int
Link copied to clipboard

Functions

Link copied to clipboard
fun animate(animationFunction: Animatable.() -> Unit)
Link copied to clipboard
open override fun draw()

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

Link copied to clipboard
fun Program.drawImage(width: Int, height: Int, contentScale: Double? = null, format: ColorFormat = ColorFormat.RGBa, type: ColorType = defaultColorType(format), multisample: BufferMultisample? = null, drawFunction: Drawer.() -> Unit): ColorBuffer

Create an image ColorBuffer by drawing it

Link copied to clipboard
open override fun drawImpl()

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

Link copied to clipboard
open override fun <T : Extension> extend(extension: T): T

install an Extension

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

install an Extension and configure it

open override fun extend(stage: ExtensionStage, userDraw: Program.() -> Unit)

install an extension function for the given ExtensionStage

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

launch a coroutine in the Program context

Link copied to clipboard
fun Program.loadFont(fileOrUrl: String, size: Double, characterSet: Set<Char> = defaultFontmapCharacterSet, contentScale: Double = this.drawer.context.contentScale, fontScaler: (Face) -> Double = ::fontHeightScaler): FontImageMap
Link copied to clipboard
expect fun Program.namedTimestamp(extension: String = "", path: String? = null): String
actual fun Program.namedTimestamp(extension: String, path: String?): String
actual fun Program.namedTimestamp(extension: String, path: String?): String
Link copied to clipboard
open suspend override fun setup()

This runs exactly once before the first call to draw()

Link copied to clipboard
open override fun updateFrameSecondsFromClock()
Link copied to clipboard
fun Program.window(configuration: WindowConfiguration = WindowConfiguration(), init: suspend Program.() -> Unit): ApplicationWindow