Logo

index : binary-tree

---

  • summary
  • about
  • tree
  • log
  • branches
<< path: root/things/binary-tree.git/html/src/gui.jai blob: 2bbb578958d3bb1971bd67f587bc5708d92daa07 [raw] [clear marker]

        
0
1
2
3gui_init :: () {
4
5}
6
7
8gui_draw_screen :: () {
9 using container;
10 x = (GetScreenWidth() / 2.0) - (WIDTH / 2.0);
11 y = GetScreenHeight() - HEIGHT;
12 width = WIDTH;
13 height = HEIGHT;
14
15 left := rcut_from_left(*container, 0.333333);
16 mid := rcut_from_left(*container, 0.5);
17 right := rcut_from_left(*container, 1.0);
18
19 SIZE :: 30.0;
20
21 draw_indicator(left, .TRAD_TREE);
22 draw_indicator(mid, .HYPER_TREE);
23 draw_indicator(right, .CELLS);
24
25 draw_text(left, "vTree", SIZE, .TRAD_TREE);
26 draw_text(mid, "hTree", SIZE, .HYPER_TREE);
27 draw_text(right, "Cells", SIZE, .CELLS);
28}
29
30gui_statistics :: (st: *Statistics) {
31 FONT_SIZE :: 20;
32
33 using st;
34 total = nodes + children + empty;
35
36 stats := tprint("Nodes: %1 | Children: %2 | Empty: %3 | Total: %4",
37 nodes,
38 children,
39 empty,
40 total
41 );
42
43 info := to_c_string(stats);
44 DrawText(
45 info,
46 SCREEN_WIDTH - MeasureText(info, FONT_SIZE) - 16,
47 SCREEN_HEIGHT - 24,
48 FONT_SIZE,
49 { 160, 160, 200, 220 }
50 );
51
52}
53
54
55#scope_file
56
57
58container: Rectangle;
59
60
61WIDTH :: 420.0;
62HEIGHT :: 60.0;
63
64
65draw_text :: (rect: Rectangle, text: string, size: float, m: Mode) {
66 color := ifx mode == m then COLOR_BACKGROUND else WHITE;
67
68 ctext := to_c_string(text);
69 mt := MeasureTextEx(GetFontDefault(), ctext, size, 1.0);
70
71 x := rect.x + (rect.width / 2.0) - (mt.x / 2.0) - 3.0;
72 y := rect.y + (rect.height / 2.0) - (mt.y / 2.0);
73
74 DrawText(ctext, xx x, xx y, xx size, color);
75}
76
77draw_indicator :: (rect: Rectangle, m: Mode) {
78 if mode == m
79 then DrawRectangleRec(rect, WHITE);
80 else DrawRectangleLinesEx(rect, 1.0, WHITE);
81}
82
83
Copyright 2026  E766CB298A6D1E64 | Git-Thing heavily inspired by cgit