Program Configuration
Starting your program with a custom configuration looks roughly like this.
fun main() = application {
configure {
// settings go here
}
program {
// -- one time set up code goes here
extend {
// -- drawing code goes here
}
}
}
Window size
Setting the window size is done through the width
and height
properties.
fun main() = application {
configure {
width = 640
height = 480
}
}
Window position
The default value for position
is null
for which the default behaviour is to place the window at the center of the primary display
fun main() = application {
configure {
position = IntVector2(100, 400)
}
}
Fullscreen window
Setting the window size is done through the width
and height
properties.
fun main() = application {
configure {
width = 1920
height = 1080
fullscreen = Fullscreen.SET_DISPLAY_MODE
}
}
or if no mode change is desired use Fullscreen.CURRENT_DISPLAY_MODE
fun main() = application {
configure {
fullscreen = Fullscreen.CURRENT_DISPLAY_MODE
}
}
Window Title
fun main() = application {
configure {
title = "Lo and behold!"
}
}
Window unfocus behaviour
Two window unfocus behaviours are available. In NORMAL
behaviour the program continues running at full speed, in contrast the THROTTLE
behaviour throttles the program to 10Hz.
fun main() = application {
configure {
unfocusBehaviour = UnfocusBehaviour.THROTTLE
}
}
Mouse visibility
It is possible to hide the mouse cursor via hideCursor
.
fun main() = application {
configure {
hideCursor = true
}
}
Changing the configuration while the program runs
To modify the configuration after the program has started we can set various properties via application
.
fun main() = application {
program {
extend {
if (frameCount % 60 == 0) {
application.cursorVisible = Random.bool()
application.windowPosition = Vector2.uniform(0.0, 200.0)
}
}
}
}