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

Represents the clipboard functionality for the application.

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>

A mutable list of extensions associated with the host. Extensions allow adding custom behavior or extending the functionality of the framework at various lifecycle stages such as setup, before draw, and after draw.

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

An event triggered when assets need to be produced or generated.

Link copied to clipboard
open override val program: Program
Link copied to clipboard

An event triggered when there is a request for assets to be accessed or provided.

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()

The draw method is responsible for rendering the current state of the program. This method is called automatically for each frame during the runtime of the program. It serves as the main function to perform all visual updates, including drawing shapes, updating visuals, and handling animations based on the current state.

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()
Link copied to clipboard
open override fun <T : Extension> extend(extension: T): T

Adds an extension to the host and returns the extension instance. The extension allows customization or extension of the host's functionality at various lifecycle stages such as setup, before draw, and after draw.

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

Adds an extension to the host and applies a configuration block to it. This method allows customization or extension of the host's functionality by invoking a user-defined configuration on the provided extension.

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

Adds an extension to the program that executes a user-defined block of code at a specified extension stage. The execution stage can be SETUP, BEFORE_DRAW, or AFTER_DRAW. This method prevents nesting of extend calls.

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

Generates a timestamped name for the program, optionally including a file extension and path.

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