import { Color } from @core:color; import { Gfx } from @sdk:gfx; declare global ticks: int = 0; declare const SCREEN_W: int = 320; declare const SCREEN_H: int = 180; declare const CELL: int = 8; [Init] fn init() -> void { ticks = 0; } fn abs_i(v: int) -> int { if (v < 0) { return -v; } return v; } [Frame] fn frame() -> void { ticks += 1; let cx : int = SCREEN_W / 2; let cy : int = SCREEN_H / 2; let phase : int = ticks / 2; Gfx.clear(new Color(33)); for y: int from 0 until SCREEN_H step CELL { let dy : int = y - cy; for x: int from 0 until SCREEN_W step CELL { let dx : int = x - cx; let md : int = abs_i(dx) + abs_i(dy); let seed_x : int = dx / 3 + ((phase % 29) - 14); let seed_y : int = dy / 3 + (((phase * 3) % 23) - 11); let zx: int = seed_x; let zy: int = seed_y; let iter: int = 0; while iter < 3 { let ax : int = abs_i(zx); let ay : int = abs_i(zy); let nx : int = ((zx * zx - zy * zy) / 48) + seed_x + ((ay * 3) / 8) - 9; let ny : int = ((ax * zy) / 24) + seed_y + ((phase + iter * 7) % 17) - 8; zx = nx; zy = ny; iter += 1; } let axf : int = abs_i(zx); let ayf : int = abs_i(zy); let ripple : int = (md / 9 + phase + ((dx - dy) / 12)) % 64; let cloud : int = ((axf * 2) + (ayf * 3) + ripple + ((x - y + phase) % 29)) % 128; let glow : int = ((abs_i(dx / 3) + abs_i(dy / 2)) / 8 + phase) % 32; let energy : int = (cloud + glow) % 128; let r : int = if energy > 95 { 6 + ((phase + x / CELL) % 6) } else if energy > 63 { 4 + ((energy + phase) % 8) } else { (energy / 24) % 3 }; let g : int = if energy > 95 { 6 + ((phase + y / CELL) % 12) } else if energy > 63 { 8 + ((energy + phase) % 14) } else { 2 + ((energy / 12) % 5) }; let b : int = if energy > 95 { 24 + ((phase + x / CELL + y / CELL) % 5) } else if energy > 63 { 18 + ((energy + phase) % 10) } else { 7 + ((energy / 6) % 12) }; let color_raw : int = r * 2048 + g * 32 + b; Gfx.fill_rect(x, y, CELL, CELL, new Color(color_raw)); } } let star_a : int = (phase * 3) % SCREEN_W; let star_b : int = (phase * 5 + 37) % SCREEN_W; let star_c : int = (phase * 7 + 91) % SCREEN_W; let star_d : int = (phase * 11 + 143) % SCREEN_W; let star_e : int = (phase * 13 + 211) % SCREEN_W; let star_f : int = (phase * 17 + 17) % SCREEN_W; let star_y0 : int = 18 + ((phase * 2) % 24); let star_y1 : int = 42 + ((phase * 3) % 18); let star_y2 : int = 70 + ((phase * 4) % 22); let star_y3 : int = 104 + ((phase * 5) % 16); let star_y4 : int = 132 + ((phase * 6) % 20); let star_y5 : int = 154 + ((phase * 7) % 14); let twinkle0 : int = phase % 6; let twinkle1 : int = (phase + 2) % 6; let twinkle2 : int = (phase + 4) % 6; let twinkle3 : int = (phase + 1) % 6; let twinkle4 : int = (phase + 3) % 6; let twinkle5 : int = (phase + 5) % 6; let star_s0 : int = 1 + (twinkle0 / 4); let star_s1 : int = 1 + (twinkle1 / 4); let star_s2 : int = 1 + (twinkle2 / 4); let star_s3 : int = 1 + (twinkle3 / 4); let star_s4 : int = 1 + (twinkle4 / 4); let star_s5 : int = 1 + (twinkle5 / 4); let star_c0 : int = 57023 + twinkle0 * 1056; let star_c1 : int = 48607 + twinkle1 * 1376; let star_c2 : int = 44383 + twinkle2 * 1584; let star_c3 : int = 61279 + twinkle3 * 704; let star_c4 : int = 40159 + twinkle4 * 1696; let star_c5 : int = 52831 + twinkle5 * 992; Gfx.fill_rect(star_a, star_y0, star_s0, star_s0, new Color(star_c0)); Gfx.fill_rect(star_b, star_y1, star_s1, star_s1, new Color(star_c1)); Gfx.fill_rect(star_c, star_y2, star_s2, star_s2, new Color(star_c2)); Gfx.fill_rect(star_d, star_y3, star_s3, star_s3, new Color(star_c3)); Gfx.fill_rect(star_e, star_y4, star_s4, star_s4, new Color(star_c4)); Gfx.fill_rect(star_f, star_y5, star_s5, star_s5, new Color(star_c5)); //Gfx.clear(new Color(33)); } // Estimated frame cost: ~920 fills + ~2760 fractal-iteration steps + 6 twinkling parallax stars/frame at CELL=8.