{
"id": "183",
"prompt": "A circular progress ring approximated with 24 segment blocks positioned by an integer sine table (rustlite has no arcs): a 0..100 percent loops with t, filled segments glow cyan while empty ones stay dim, and the percent number plus a % sign sit in the middle of the ring.",
"solution_rl": "fn sv(i: i32) -> i32 {\n let tab = [0, 25, 49, 71, 90, 106, 117, 124, 127, 124, 117, 106, 90, 71, 49, 25, 0, -25, -49, -71, -90, -106, -117, -124, -127, -124, -117, -106, -90, -71, -49, -25];\n tab[i & 31]\n}\n\nfn frame(t: i32) {\n let w: i32 = host::display::width();\n let h: i32 = host::display::height();\n let cx: i32 = w / 2;\n let cy: i32 = h / 2;\n let r: i32 = if w < h { w / 2 - 40 } else { h / 2 - 40 };\n let pct: i32 = (t / 3) % 101;\n host::display::clear(0x08080c);\n let mut i: i32 = 0;\n while i < 24 {\n let idx: i32 = i * 32 / 24;\n let x: i32 = cx + sv(idx) * r / 127;\n let y: i32 = cy - sv(idx + 8) * r / 127;\n let col: i32 = if i < pct * 24 / 100 { 0x00e0ff } else { 0x1a1a22 };\n host::display::fill_rect(x - 7, y - 7, 15, 15, col);\n i = i + 1;\n }\n host::display::draw_number(cx - 28, cy - 12, pct, 0xffffff, 3);\n host::display::draw_string(cx + 24, cy - 12, \"%\", 0x808080, 3);\n host::display::present();\n}\n",
"tags": [
"gauge",
"trig-table",
"modulo"
]
}