info = { type = "image", title = "BTC sun", category = "btc", author = "BRRRO", version = "1.0", license = "MIT", desc = "Desert sunset with a bitcoin sun", api = 44, } local ND, NS = 64, 48 local D1 = 44 local D2 = D1 + ND local SU = D2 + 1 local GL = SU + NS local BTC = { "00101000","11111100","01100110","01100110","01111100","01100011","01100011","11111110","00101000" } local GRID, PAL, SUNC, CELL, STAGE = nil, nil, nil, nil, 1 local W, H, FPS = gfx.W, gfx.H, gfx.FPS local floor, sqrt, sin = math.floor, math.sqrt, math.sin local STAGES = { function() PAL = {} for y = 0, 43 do local tt, r, g, b = y / 43 if tt < 0.45 then local f = tt / 0.45 r, g, b = 58 + 156 * f, 26 + 58 * f, 54 - 14 * f else local f = (tt - 0.45) / 0.55 r, g, b = 214 + 41 * f, 84 + 116 * f, 40 + 56 * f end PAL[3 * y + 1], PAL[3 * y + 2], PAL[3 * y + 3] = r // 1, g // 1, b // 1 end for k = 0, ND - 1 do local f = (k + 0.5) / ND PAL[3 * (D1 + k) + 1] = (176 - 80 * f) // 1 PAL[3 * (D1 + k) + 2] = (112 - 54 * f) // 1 PAL[3 * (D1 + k) + 3] = ( 52 - 26 * f) // 1 end PAL[3 * D2 + 1], PAL[3 * D2 + 2], PAL[3 * D2 + 3] = 58, 34, 16 PAL[3 * GL + 1], PAL[3 * GL + 2], PAL[3 * GL + 3] = 120, 52, 12 SUNC = {} for k = 0, NS - 1 do local f = (k + 0.5) / NS SUNC[3 * k + 1] = 255 - 15 * f SUNC[3 * k + 2] = 214 - 94 * f SUNC[3 * k + 3] = 110 - 80 * f end CELL = {} for y = 0, H - 1 do local v, row = y < 44 and y or 43, {} for x = 1, W do row[x] = v end CELL[y] = row end end, function() local cx, cy, R = 31.5, 30, 11.6 for y = 18, 42 do for x = 19, 44 do local dx, dy = x - cx, y - cy local dd = sqrt(dx * dx + dy * dy) if dd <= R then local k = floor(dd / R * NS) if k >= NS then k = NS - 1 end CELL[y][x + 1] = SU + k end end end for r = 1, 9 do local row = BTC[r] for c = 1, 8 do if row:sub(c, c) == "1" then CELL[25 + r][28 + c] = GL end end end end, function() for x = 0, W - 1 do local h1 = 45 + floor(3 * sin(x * 0.16) + 0.5) for y = h1, H - 1 do local k = floor((y - h1) / (H - h1) * ND) if k >= ND then k = ND - 1 end CELL[y][x + 1] = D1 + k end local h2 = 54 + floor(2 * sin(x * 0.12 + 1.7) + 0.5) for y = h2, H - 1 do CELL[y][x + 1] = D2 end end end, function() local rows = {} for y = 0, H - 1 do rows[y + 1] = string.char(table.unpack(CELL[y], 1, W)) end GRID = table.concat(rows) CELL = nil end, } function render() if not GRID then STAGES[STAGE]() STAGE = STAGE + 1 if not GRID then gfx.ready(false) return end end local t = frame / FPS local gl = 0.92 + 0.08 * math.sin(t * 3) for k = 0, NS - 1 do PAL[3 * (SU + k) + 1] = SUNC[3 * k + 1] * gl // 1 PAL[3 * (SU + k) + 2] = SUNC[3 * k + 2] * gl // 1 PAL[3 * (SU + k) + 3] = SUNC[3 * k + 3] * gl // 1 end gfx.blit_indexed(GRID, PAL, 0, 0, W, H, W, H) for i = 0, 9 do if math.sin(t * 4.8 + i) > 0.4 then gfx.px((i * 53 + 9) % W, (i * 17 + 3) % 18, 255, 228, 180) end end end