Files
kryon/examples/06_scaling.kry
T
2026-08-09 19:52:01 -03:00

42 lines
1.1 KiB
Plaintext

#import "kryon.h"
app "Kryon Scaling Example" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
scale_index: int = 0
scales: [4] float = {1.0f,1.5f,2.0f,2.5f}
box_x: int = 100
box_y: int = 100
}
screen ScalingExample(viewport: Rectangle) {
SetUIScale(scales[scale_index])
Background(GetThemeBackground())
box_size: int = ScaleUIPx(100)
Text(TextFormat("DPI Scale:%.1f",scales[scale_index]), 50, 20, 20, GetThemeText())
Rect(box_x, box_y, box_size, box_size, GetThemeButton(), GetThemeIcon())
Text("Scaled Box", box_x + 10, box_y + 10, UI_TEXT_16, GetThemeText())
Text(TextFormat("Base:100px Scaled:%dpx",box_size), 50, 60, UI_TEXT_16, GetThemeText())
Text("SPACE cycles DPI,arrows move box", 50, 90, UI_TEXT_16, GetThemeIcon())
if (IsKeyDown(KEY_RIGHT)) {
box_x += 3
}
if (IsKeyDown(KEY_LEFT)) {
box_x -= 3
}
if (IsKeyDown(KEY_DOWN)) {
box_y += 3
}
if (IsKeyDown(KEY_UP)) {
box_y -= 3
}
if (IsKeyPressed(KEY_SPACE)) {
scale_index = (scale_index + 1) % 4
}
}