info = { type = "image", title = "Sunset", category = "nature", author = "BRRRO", version = "1.0", license = "MIT", desc = "The sun sets into the sea, a palm in front", api = 33, } local HZ = 36 local GX, GW = 27, 10 local GPAL = { 0, 0, 0, 255, 222, 162 } local cells, TRUNK, LEAF, BG = {}, nil, nil, nil function render() local W, H, FPS = gfx.W, gfx.H, gfx.FPS local floor, sin, cos = math.floor, math.sin, math.cos if not TRUNK then TRUNK, LEAF = {}, {} for y = 30, 57 do TRUNK[#TRUNK + 1] = 8 + floor(sin(y * 0.12) * 1.6 + 0.5) TRUNK[#TRUNK + 1] = y end for lf = 0, 4 do local an = -1.0 + lf * 0.45 local ca, sa = cos(an), sin(an) for r = 0, 9 do local x, y = 8 + floor(ca * r + 0.5), 30 + floor(sa * r * 0.7 + 0.5) if x >= 0 and x < W and y >= 0 then LEAF[#LEAF + 1] = x LEAF[#LEAF + 1] = y end end end end if BG then gfx.blit_rgb(BG, 0, 0, W, H) else for y = 0, HZ - 1 do local f = y / HZ gfx.rect(0, y, W, 1, 255, 150 + 74 * f, 70 + 80 * f) end for y = HZ, H - 1 do local f = (y - HZ) / (H - HZ) gfx.rect(0, y, W, 1, 176 - 84 * f, 92 - 40 * f, 84 + 8 * f) end for yy = 13, 31 do local dy = yy - 22 local hw = floor(math.sqrt(82 - dy * dy)) gfx.rect(32 - hw, yy, 2 * hw + 1, 1, 255, 232, 156) end for j = 1, #TRUNK, 2 do gfx.px(TRUNK[j], TRUNK[j + 1], 48, 34, 30) end for j = 1, #LEAF, 2 do gfx.px(LEAF[j], LEAF[j + 1], 40, 86, 48) end BG = gfx.snapshot(0, 0, W, H) end local k, i = floor(frame * 24 / FPS), 1 for y = HZ, H - 1 do local b = (y + k) % 5 for x = GX, GX + GW - 1 do cells[i] = (x * 3 + b) % 5 < 2 and 1 or 0 i = i + 1 end end gfx.blit_indexed(cells, GPAL, GX, HZ, GW, H - HZ, GW, H - HZ, true) end