UI Card Demo Source

assets/source/main.oren · 0.1.0

Back to package · Browse packages

1import ui_avm "std:ui/avm"
2
3fn fail(msg) {
4    print("FAIL")
5    print(msg)
6    oren_exit(1)
7}
8
9fn main() {
10    var cmds = [
11        {"op": "fill_rect", "x": 0, "y": 0, "w": 320, "h": 180, "color": "#102820"},
12        {"op": "fill_rect", "x": 18, "y": 18, "w": 284, "h": 144, "color": "#f5efe0"},
13        {"op": "stroke_line", "x1": 18, "y1": 128, "x2": 302, "y2": 128, "width": 2, "color": "#146c5b"},
14        {"op": "circle", "cx": 272, "cy": 58, "r": 28, "fill": true, "color": "#e38b29"},
15        {"op": "text", "x": 34, "y": 52, "color": "#102820", "text": "Oren AVM UI"},
16        {"op": "text", "x": 34, "y": 92, "color": "#36584d", "text": "Binary OGF0 frame demo"}
17    ]
18    var rc = ui_avm.present_frame(cmds, 320, 180, {
19        "sequence": 1,
20        "scale_milli": 3000,
21        "drawable_w": 960,
22        "drawable_h": 540,
23        "target_hz_milli": 120000,
24        "strict_bounds": true
25    })
26    if oren_is_err(rc) { fail(oren_err_msg(rc)) }
27    if rc != 0 { fail("present_frame") }
28    print("ui-card demo OK")
29    oren_exit(0)
30}
31