info = { type = "image", title = "Eye of Horus wall", category = "other", author = "BRRRO", version = "1.0", license = "MIT", desc = "Torchlight reveals a hieroglyph wall and eye", api = 44, } local tr = ({ sk = { ["Torch pace"] = "Tempo pochodne", ["Glyph colour"] = "Farba znakov", ["slow"] = "pomaly", ["normal"] = "bežne", ["fast"] = "rýchlo" }, cs = { ["Torch pace"] = "Tempo pochodně", ["Glyph colour"] = "Barva znaků", ["slow"] = "pomalu", ["normal"] = "běžně", ["fast"] = "rychle" }, })[lang] or {} local function T(s) return tr[s] or s end settings = { { key = "pace", label = T("Torch pace"), type = "int", default = "normal", opts = { keys = { "slow", "normal", "fast" }, T("slow"), T("normal"), T("fast") } }, { key = "ink", label = T("Glyph colour"), type = "color", default = "#188A84" }, } local rect, px, blend_rect, blend = gfx.rect, gfx.px, gfx.blend_rect, gfx.blend local floor, sin, cos, sqrt, abs, min, max = math.floor, math.sin, math.cos, math.sqrt, math.abs, math.min, math.max local hash32, umod = math.hash32, math.umod local W, H = gfx.W, gfx.H local EX, EY = 32, 31 local function sstep(a, b, t) local u = (t - a) / (b - a) if u <= 0 then return 0 elseif u >= 1 then return 1 end return u * u * (3 - 2 * u) end local GL = { ".###.#...#.###.#####..#....#....#..", "..##..###.#####.####..##...#...###.", ".....#..#..##.#.....#..#..##.#.....", "......###.#.#.#.###...#....#.......", ".###.#...##.#.##...#.###.......#...", ".#.#...#..#####.###.#####.###...#..", } for i = 1, #GL do GL[i] = ((GL[i]:gsub("#", "\1")):gsub("%.", "\0")) end local WALL, MASK, stage = nil, nil, 0 local RM = 28 local MS = 2 * RM + 1 local INK = { 24, 138, 132 } local OCH = { 128, 74, 30 } local DARK = { 8, 5, 6 } local DA = 230 / 255 local function glyph_row(y) for i = 0, 7 do local h = hash32((y * 31 + i) * 0x9E3779B1) local c = (i % 2 == 0) and INK or OCH gfx.blit_indexed(GL[umod(h >> 8, #GL) + 1], { 0, 0, 0, c[1], c[2], c[3] }, 5 + i * 7, y, 5, 7, 5, 7, true) end end local function bake_wall() rect(0, 0, W, H, 190, 154, 100) for i = 0, 70 do local h = hash32(i * 0x85EBCA6B + 11) local c = (h & 1) == 0 and 176 or 204 px(umod(h >> 4, W), umod(h >> 12, H), c, floor(c * 0.8), floor(c * 0.54)) end for course = 0, 3 do local y = course * 16 if course > 0 then rect(0, y - 1, W, 1, 150, 114, 70) end for k = 0, 2 do local x = (course % 2 == 0) and (10 + k * 22) or (21 + k * 22) if x < W then rect(x, y, 1, 15, 150, 114, 70) end end end for _, y in ipairs({ 1, 58 }) do rect(0, y, W, 5, INK[1], INK[2], INK[3]) for x = 0, W - 1, 4 do px(x + 1, y + 2, 224, 176, 60) end end glyph_row(9) glyph_row(49) WALL = gfx.snapshot(0, 0, W, H) end local function bake_eye() gfx.blit_rgb(WALL, 0, 0, W, H) local K = { 40, 24, 16 } for dy = -7, 7 do local hw = floor(23 * (1 - (abs(dy) / 8) ^ 1.7) + 0.5) rect(EX - hw - 1, EY + dy, 2 * hw + 2, 1, K[1], K[2], K[3]) if abs(dy) < 7 then rect(EX - hw + 1, EY + dy, 2 * hw - 2, 1, 238, 226, 190) end end for dy = -4, 4 do local hw = floor(sqrt(21 - dy * dy) + 0.5) rect(EX + 1 - hw, EY + dy, 2 * hw, 1, 24, 146, 146) end rect(EX, EY - 1, 3, 3, 10, 14, 20) rect(EX + 21, EY, 9, 2, K[1], K[2], K[3]) for i = 0, 5 do local x = EX - 24 + i * 8 local y = EY - 12 - floor(3 * (1 - ((x + 4 - EX) / 26) ^ 2) + 0.5) rect(x, y, 9, 2, K[1], K[2], K[3]) end rect(EX + 4, EY + 7, 2, 9, K[1], K[2], K[3]) rect(EX + 3, EY + 16, 4, 1, K[1], K[2], K[3]) rect(EX + 2, EY + 17, 6, 1, K[1], K[2], K[3]) for i = 0, 5 do px(EX - 9 - i * 2, EY + 8 + floor(i * 0.6), K[1], K[2], K[3]); px(EX - 10 - i * 2, EY + 8 + floor(i * 0.6), K[1], K[2], K[3]) end for a = 0, 11 do local r = a * 0.5236 px(EX - 22 + floor(3.2 * cos(r) + 0.5), EY + 11 + floor(3.2 * sin(r) + 0.5), K[1], K[2], K[3]) end px(EX - 22, EY + 11, K[1], K[2], K[3]) WALL = gfx.snapshot(0, 0, W, H) end local function bake_mask() local rows, row = {}, {} for y = -RM, RM do for x = -RM, RM do local d = sqrt(x * x + y * y) / RM row[x + RM + 1] = d <= 0.22 and 0 or d >= 1 and 230 or floor(230 * (d - 0.22) / 0.78) end rows[y + RM + 1] = string.char(table.unpack(row, 1, MS)) end MASK = table.concat(rows) end local MULT = 1.0 function on_settings() local p = cfg.pace MULT = p == "slow" and 0.7 or p == "fast" and 1.4 or 1.0 local c = cfg.ink or { r = 24, g = 138, b = 132 } INK[1], INK[2], INK[3] = c.r, c.g, c.b stage = 0 WALL, MASK = nil, nil end local P = { {6,58}, {9,40}, {12,24}, {22,19}, {36,22}, {52,19}, {58,34}, {52,52}, {36,56}, {22,54}, {14,46}, {24,48}, {32,49}, {32,49}, {32,49}, {32,49} } local SEG, CYC = 80, 1200 local function cr(p0, p1, p2, p3, u) return 0.5 * (2 * p1 + (p2 - p0) * u + (2 * p0 - 5 * p1 + 4 * p2 - p3) * u * u + (3 * p1 - p0 - 3 * p2 + p3) * u * u * u) end local function dark(x, y, w, h) local x0, y0, x1, y1 = max(x, 0), max(y, 0), min(x + w, W), min(y + h, H) if x1 > x0 and y1 > y0 then blend_rect(x0, y0, x1 - x0, y1 - y0, DARK[1], DARK[2], DARK[3], DA) end end local function flame(fx, fy, k, s) rect(fx - 1, fy + 3, 2, 14, 96, 62, 34) rect(fx - 2, fy + 2, 4, 2, 70, 44, 26) if s < 0.35 then px(fx, fy, 255, 150, 40) return end local sway = (k % 3) - 1 rect(fx - 2, fy - 2, 4, 5, 255, 132, 28) rect(fx - 1, fy - 4, 2, 3, 255, 132, 28) px(fx - 1 + sway, fy - 5, 255, 150, 40) if s > 0.7 then px(fx - (k % 2), fy - 6 - (k % 2), 255, 150, 40) end rect(fx - 1, fy - 2, 2, 4, 255, 206, 70) rect(fx - 1, fy, 2, 2, 255, 244, 190) end function render() if stage < 3 then stage = stage + 1 if stage == 1 then bake_wall() elseif stage == 2 then bake_eye() else bake_mask() end if stage < 3 then gfx.ready(false) return end end gfx.blit_rgb(WALL, 0, 0, W, H) local ti = (frame * MULT) % CYC local si = floor(ti / SEG) + 1 local u = (ti - (si - 1) * SEG) / SEG local a, b, c, d = P[max(si - 1, 1)], P[si], P[si + 1], P[min(si + 2, #P)] local fx, fy = cr(a[1], b[1], c[1], d[1], u), cr(a[2], b[2], c[2], d[2], u) local lit = sstep(0, 40, ti) * (1 - sstep(1150, 1200, ti)) local R = (17 + 10 * sstep(700, 960, ti)) * lit R = floor(R + 0.7 * sin(frame * 0.9) + 0.6 * sin(frame * 0.37) * lit + 0.5) local cx, cy = floor(fx + 0.5), floor(fy + 0.5) - 6 if R > 1 then gfx.blend_mask(MASK, DARK[1], DARK[2], DARK[3], cx - R, cy - R, 2 * R + 1, 2 * R + 1, MS, MS, 1) dark(0, 0, W, cy - R) dark(0, cy + R + 1, W, H - (cy + R + 1)) dark(0, cy - R, cx - R, 2 * R + 1) dark(cx + R + 1, cy - R, W - (cx + R + 1), 2 * R + 1) else dark(0, 0, W, H) end for _, g0 in ipairs({ 1010, 1110 }) do local g = ti - g0 if g > 0 and g < 26 then local L = floor(3.4 * sin(g / 26 * 3.14159) + 0.5) local gx, gy = EX - 1, EY - 2 rect(gx - L, gy, 2 * L + 1, 1, 255, 255, 235) rect(gx, gy - L, 1, 2 * L + 1, 255, 255, 235) if L > 1 then px(gx - 1, gy - 1, 255, 255, 235); px(gx + 1, gy + 1, 255, 255, 235) end blend_rect(EX - 4, EY - 4, 9, 9, 255, 250, 220, 0.12 * sin(g / 26 * 3.14159)) end end flame(floor(fx + 0.5), floor(fy + 0.5), floor(frame / 2) + umod(hash32(floor(frame / 3)), 3), lit) end