Program

Represents a program interface that combines input event handling, extension hosting, and clock functionalities. It provides common properties and methods for managing the lifecycle of a program, drawing operations, and asset management.

Inheritors

Properties

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

Represents the clipboard functionality for the application.

Link copied to clipboard
abstract var clock: () -> Double
Link copied to clipboard
abstract val dispatcher: Dispatcher
Link copied to clipboard
abstract var drawer: Drawer
Link copied to clipboard
abstract var driver: Driver
Link copied to clipboard
abstract var ended: Event<ProgramEvent>

Event that is triggered when the program ends.

Link copied to clipboard

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
abstract val frameCount: Int
Link copied to clipboard
abstract var height: Int
Link copied to clipboard
abstract var isNested: Boolean
Link copied to clipboard
abstract val keyboard: KeyEvents
Link copied to clipboard
abstract val mouse: MouseEvents
Link copied to clipboard
abstract var name: String
Link copied to clipboard
abstract val pointers: Pointers
Link copied to clipboard

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

Link copied to clipboard
abstract 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
abstract val seconds: Double
Link copied to clipboard

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

Link copied to clipboard
abstract var width: Int
Link copied to clipboard
abstract val window: Window

Functions

Link copied to clipboard
abstract 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
abstract fun drawImpl()
Link copied to clipboard
abstract 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.

abstract 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.

abstract fun extend(stage: ExtensionStage = ExtensionStage.BEFORE_DRAW, 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
abstract suspend fun setup()
Link copied to clipboard
Link copied to clipboard
fun Program.window(configuration: WindowConfiguration = WindowConfiguration(), init: suspend Program.() -> Unit): ApplicationWindow