Files
kryon/examples/27_inbe_statistics.kry
T
waozi 6f5f8f56d4 examples: statistics screen cartridge
Stat cards with state-bound counters (TextFormat), a seven-bar week
chart from guarded rects, axis labels. Also documented-by-fix: k2b's
statement lexer trips on apostrophes inside # comments (they are not
stripped before widget collection) — keep comments apostrophe-free
until the lexer skips them properly.
2026-08-17 08:03:57 -03:00

52 lines
2.1 KiB
Plaintext

# Inner Breeze statistics screen cartridge
#import "kryon.h"
state {
sessions: int = 24
minutes: int = 186
streak: int = 6
best: int = 41
bar1: int = 30
bar2: int = 55
bar3: int = 20
bar4: int = 70
bar5: int = 45
bar6: int = 60
bar7: int = 35
}
app "Inner Breeze — Statistics" {
size 480 640
fps 60
frame main
}
frame main {
BeginDrawing()
ClearBackground(GetThemeBackground())
BeginUIFrame(GetScreenWidth(), GetScreenHeight(), GetUIScale())
Background(GetThemeBackground())
Text("Statistics", ScaleUIPx(141), ScaleUIPx(28), UI_TEXT_24, GetThemeText())
Text("Sessions", ScaleUIPx(52), ScaleUIPx(88), UI_TEXT_12, GetThemeIcon())
TextFormat("%d", sessions, ScaleUIPx(52), ScaleUIPx(102), UI_TEXT_16, GetThemeText())
Text("Minutes", ScaleUIPx(184), ScaleUIPx(88), UI_TEXT_12, GetThemeIcon())
TextFormat("%d", minutes, ScaleUIPx(184), ScaleUIPx(102), UI_TEXT_16, GetThemeText())
Text("Streak", ScaleUIPx(316), ScaleUIPx(88), UI_TEXT_12, GetThemeIcon())
TextFormat("%d days", streak, ScaleUIPx(316), ScaleUIPx(102), UI_TEXT_16, GetThemeText())
Text("Best round", ScaleUIPx(52), ScaleUIPx(160), UI_TEXT_12, GetThemeIcon())
TextFormat("%d breaths", best, ScaleUIPx(52), ScaleUIPx(174), UI_TEXT_16, GetThemeText())
Text("This week", ScaleUIPx(52), ScaleUIPx(240), UI_TEXT_16, GetThemeText())
Rect(ScaleUIPx(52), ScaleUIPx(270), ScaleUIPx(16), bar1, GetThemeButton())
Rect(ScaleUIPx(76), ScaleUIPx(270), ScaleUIPx(16), bar2, GetThemeButton())
Rect(ScaleUIPx(100), ScaleUIPx(270), ScaleUIPx(16), bar3, GetThemeButton())
Rect(ScaleUIPx(124), ScaleUIPx(270), ScaleUIPx(16), bar4, GetThemeButton())
Rect(ScaleUIPx(148), ScaleUIPx(270), ScaleUIPx(16), bar5, GetThemeButton())
Rect(ScaleUIPx(172), ScaleUIPx(270), ScaleUIPx(16), bar6, GetThemeButton())
Rect(ScaleUIPx(196), ScaleUIPx(270), ScaleUIPx(16), bar7, GetThemeButton())
Text("M T W T F S S", ScaleUIPx(50), ScaleUIPx(340), UI_TEXT_12, GetThemeIcon())
Text("Totals update after each session", ScaleUIPx(52), ScaleUIPx(400), UI_TEXT_12, GetThemeIcon())
EndUIFocus()
EndDrawing()
}