info = { type = "image", title = "Aurora", category = "nature", author = "BRRRO", version = "1.0", license = "MIT", desc = "Northern lights over a snowy horizon", api = 33, } local Y0, ROWS = 8, 27 local BANDC = { 80, 240, 170, 120, 200, 255, 200, 140, 255 } local PAL = { 0, 0, 0 } for band = 0, 2 do local r, g, b = BANDC[band * 3 + 1], BANDC[band * 3 + 2], BANDC[band * 3 + 3] for h = 0, 4 do local a = (5 - h) / 5 local i = 3 * (band * 5 + h) + 4 PAL[i] = math.min(255, r * a + 30) // 1 PAL[i + 1] = math.min(255, g * a + 34) // 1 PAL[i + 2] = math.min(255, b * a + 44) // 1 end end local cells, HOR, BG = {}, nil, nil function render() local W, H, FPS = gfx.W, gfx.H, gfx.FPS local t = frame / FPS local floor, sin = math.floor, math.sin if not HOR then HOR = {} local x0, hp = 0, nil for x = 0, W do local h if x < W then h = 52 - floor(2 * sin(x * 0.1) + 0.5) end if h ~= hp then if hp then HOR[#HOR + 1] = x0; HOR[#HOR + 1] = hp; HOR[#HOR + 1] = x - x0 end x0, hp = x, h end end end if not BG then for y = 0, H - 1 do local f = y / H gfx.rect(0, y, W, 1, 20 + 26 * f, 28 + 32 * f, 66 + 40 * f) end BG = gfx.snapshot(0, 0, W, H) else gfx.blit_rgb(BG, 0, 0, W, H) end for i = 0, 25 do if sin(t * 6 + i) > 0.2 then gfx.px((i * 47 + 11) % W, (i * 31 + 5) % 40, 232, 238, 255) end end for i = 1, W * ROWS do cells[i] = 0 end local ph = t * 3 for band = 0, 2 do local base, bp, top = band * 5 + 1, ph + band, 14 + band * 5 for x = 0, W - 1 do local i = (top + floor(6 * sin(x * 0.12 + bp) + 0.5) - Y0) * W + x + 1 for h = 0, 4 do cells[i] = base + h i = i + W end end end gfx.blit_indexed(cells, PAL, 0, Y0, W, ROWS, W, ROWS, true) for i = 1, #HOR, 3 do local y = HOR[i + 1] gfx.rect(HOR[i], y, HOR[i + 2], H - y, 210, 222, 240) end end