info = { type = "image", title = "Rainbow", category = "nature", author = "BRRRO", version = "1.0", license = "MIT", desc = "Rainbow arcs and two little clouds", api = 33, } local RC = { {255,90,90}, {255,170,70}, {255,230,90}, {110,210,120}, {100,180,255}, {170,120,240} } local PUFF = { {12,16}, {52,12} } local POFF = { {0,0,3}, {3,1,2}, {-3,1,2}, {1,-1,2} } local GRID, PAL function render() local W, H = gfx.W, gfx.H if not GRID then local floor, sqrt = math.floor, math.sqrt PAL = {} for y = 0, H - 1 do local f = y / H PAL[3 * y + 1] = (170 + 44 * f) // 1 PAL[3 * y + 2] = (206 + 22 * f) // 1 PAL[3 * y + 3] = (240 + 6 * f) // 1 end local base = H for i = 1, 6 do local c = RC[i] PAL[3 * (base + i - 1) + 1] = c[1] PAL[3 * (base + i - 1) + 2] = c[2] PAL[3 * (base + i - 1) + 3] = c[3] end PAL[3 * (base + 6) + 1] = 252 PAL[3 * (base + 6) + 2] = 254 PAL[3 * (base + 6) + 3] = 255 local cell = {} for y = 0, H - 1 do local row = {} for x = 1, W do row[x] = y end cell[y] = row end for band = 0, 5 do local R = 46 - band * 2 for x = 0, W - 1 do local dx = x - 32 local ins = R * R - dx * dx if ins >= 0 then local yy = 58 - floor(sqrt(ins) + 0.5) if yy >= 0 and yy < H then cell[yy][x + 1] = base + band end end end end for p = 1, 2 do local pcx, pcy = PUFF[p][1], PUFF[p][2] for o = 1, 4 do local ox, oy, rr = POFF[o][1], POFF[o][2], POFF[o][3] for yy = -rr, rr do local Y = pcy + oy + yy if Y >= 0 and Y < H then local w = floor(sqrt(rr * rr - yy * yy)) for X = pcx + ox - w, pcx + ox + w do if X >= 0 and X < W then cell[Y][X + 1] = base + 6 end end end end end end local rows = {} for y = 0, H - 1 do rows[y + 1] = string.char(table.unpack(cell[y], 1, W)) end GRID = table.concat(rows) end gfx.blit_indexed(GRID, PAL, 0, 0, W, H, W, H) end