info = { type = "image", title = "Neon city", category = "city", author = "BRRRO", version = "1.0", license = "MIT", desc = "A blue night city with neon windows", api = 33, } local BPAL = { 32,42,84, 96,150,230 } local FPAL = { 16,20,44, 244,72,60, 255,238,184, 120,176,240 } local BDARK, FDARK = string.rep("\0", 10), string.rep("\0", 9) local BROW, FROW = {}, {} do local b = {} for q = 0, 1 do for i = 0, 9 do b[i + 1] = ((i + q) % 2 == 0) and 1 or 0 end BROW[q] = string.char(table.unpack(b, 1, 10)) end for p = 0, 3 do local per = {} for c = 1, 3 do for i = 0, 8 do b[i + 1] = (i % 4 == p) and c or 0 end per[c] = string.char(table.unpack(b, 1, 9)) end FROW[p] = per end end local rows = {} local BG function render() local W, H = gfx.W, gfx.H local t = frame / gfx.FPS local floor, ceil, concat = math.floor, math.ceil, table.concat local blit = gfx.blit_indexed if BG then gfx.blit_rgb(BG, 0, 0, W, H) else for y = 0, H - 1 do local f = y / H gfx.rect(0, y, W, 1, 18 + 26 * f, 24 + 34 * f, 54 + 54 * f) end BG = gfx.snapshot(0, 0, W, H) end for i = 0, 15 do if math.sin(t * 4.2 + i) > 0.2 then gfx.px((i * 41 + 7) % W, (i * 23 + 3) % 14, 176, 194, 236) end end local off = t * 3 local ioff = floor(off) local bi = floor(off / 10) local x0 = ceil(bi * 10 - off) while x0 < W do local h = 14 + (bi * 97) % 7 * 4 local top = 52 - h local y0 = top > 0 and top or 0 local lit = BROW[(x0 + ioff) % 2] local n = 0 for y = y0, 51 do n = n + 1 if y > top + 1 and y % 2 == 0 and (bi * 7 + y) % 5 ~= 0 then rows[n] = lit else rows[n] = BDARK end end blit(concat(rows, "", 1, n), BPAL, x0, y0, 10, n, 10, n) bi, x0 = bi + 1, x0 + 10 end local foff = t * 7.2 local fioff = floor(foff) local kt = floor(t * 1.875) bi = floor(foff / 9) x0 = ceil(bi * 9 - foff) while x0 < W do local h = 20 + (bi * 131) % 6 * 5 local top = 62 - h local y0 = top > 0 and top or 0 local per = FROW[(1 - x0 - fioff) % 4] local n = 0 for y = y0, 61 do n = n + 1 if y > top + 2 and y % 4 == 1 then local k = (bi * 13 + y * 7 + kt) % 19 rows[n] = per[k == 0 and 1 or (k == 1 and 2 or 3)] else rows[n] = FDARK end end blit(concat(rows, "", 1, n), FPAL, x0, y0, 9, n, 9, n) bi, x0 = bi + 1, x0 + 9 end end