{
"id": "217",
"prompt": "Two-source ripple interference: sum two 32-entry sine-table waves indexed by each 8px cell's squared distance to two fixed sources (shifted right 8 bits, minus t so the rings travel outward) and map the sum to a blue-white water shade. Squared distance makes rings crowd together further out - embrace it.",
"solution_rl": "fn frame(t: 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 let w: i32 = host::display::width();\n let h: i32 = host::display::height();\n let ax: i32 = w / 3;\n let ay: i32 = h / 2;\n let bx: i32 = w * 2 / 3;\n let by: i32 = h / 2;\n let cell: i32 = 8;\n let mut y: i32 = 0;\n while y < h {\n let mut x: i32 = 0;\n while x < w {\n let mx: i32 = x + cell / 2;\n let my: i32 = y + cell / 2;\n let d1: i32 = (mx - ax) * (mx - ax) + (my - ay) * (my - ay);\n let d2: i32 = (mx - bx) * (mx - bx) + (my - by) * (my - by);\n let v: i32 = tab[((d1 >> 8) - t) & 31] + tab[((d2 >> 8) - t) & 31];\n let b: i32 = (v + 254) * 255 / 508;\n let c: i32 = (b / 4) * 65536 + (b * 2 / 3) * 256 + b;\n host::display::fill_rect(x, y, cell, cell, c);\n x = x + cell;\n }\n y = y + cell;\n }\n host::display::present();\n}\n",
"tags": [
"generative",
"trig-table",
"math",
"animation"
]
}