info = { type = "image", title = "Backrooms camera", category = "city", author = "BRRRO", version = "1.0", license = "MIT", desc = "Camera footage of a yellow hall with REC", api = 33, } local ltr = ({ sk = { ["REC colour"] = "Farba REC", ["Camera shake"] = "Chvenie kamery", ["Dark figure"] = "Tmavá postava" }, cs = { ["REC colour"] = "Barva REC", ["Camera shake"] = "Chvění kamery", ["Dark figure"] = "Tmavá postava" }, })[lang] or {} local function LT(s) return ltr[s] or s end settings = { { key = "rec", label = LT("REC colour"), type = "color", default = "#FF2A2A" }, { key = "shake", label = LT("Camera shake"), type = "int", min = 0, max = 3, default = 1 }, { key = "runner", label = LT("Dark figure"), type = "bool", default = true }, } local rect, px, blend_rect = gfx.rect, gfx.px, gfx.blend_rect local floor, sin, abs, max, min = math.floor, math.sin, math.abs, math.max, math.min local hash32, umod = math.hash32, math.umod local W, H, FPS = gfx.W, gfx.H, gfx.FPS local STEP_HZ = 30 local CX, CY = 32, 30 local A, B1, B2 = 34, 20, 30 local ZE = 3.6 local EX0, EX1, EY0, EY1 = 23, 41, 24, 38 local function sc(c, f) return { floor(c[1] * f + 0.5), floor(c[2] * f + 0.5), floor(c[3] * f + 0.5) } end local function mkpal(f) return { wl = sc({ 232, 204, 76 }, f), wr = sc({ 208, 180, 56 }, f), endw = sc({ 244, 222, 120 }, f), ce = { sc({ 248, 238, 194 }, f), sc({ 242, 230, 176 }, f), sc({ 238, 224, 160 }, f) }, fl = { sc({ 206, 168, 98 }, f), sc({ 190, 152, 82 }, f), sc({ 174, 136, 66 }, f) }, base = sc({ 140, 100, 36 }, f), stripe = sc({ 198, 168, 58 }, f), frame = sc({ 130, 88, 30 }, f), dr = sc({ 196, 140, 54 }, f), knob = sc({ 255, 238, 150 }, f), seam = sc({ 150, 112, 46 }, f), lamp = f < 1 and { 206, 198, 162 } or { 255, 253, 228 }, lampoff = sc({ 210, 190, 112 }, f), } end local PALS = { mkpal(1), mkpal(0.78) } local BG = {} local function build_bg(p) local c for x = 0, W - 1 do local dx = x < CX and (CX - 0.5 - x) or (x + 0.5 - CX) local k = dx / A local yt = floor(CY - B1 * k + 0.5) local yb = floor(CY + B2 * k + 0.5) local isend = dx < A / ZE if isend then yt, yb = EY0, EY1 + 1 end c = p.ce[1]; rect(x, 0, 1, min(yt, 8), c[1], c[2], c[3]) if yt > 8 then c = p.ce[2]; rect(x, 8, 1, min(yt, 18) - 8, c[1], c[2], c[3]) end if yt > 18 then c = p.ce[3]; rect(x, 18, 1, yt - 18, c[1], c[2], c[3]) end c = isend and p.endw or (x < CX and p.wl or p.wr) rect(x, yt, 1, yb - yt, c[1], c[2], c[3]) if yb < 42 then c = p.fl[3]; rect(x, yb, 1, 42 - yb, c[1], c[2], c[3]) end if yb < 52 then c = p.fl[2]; rect(x, max(yb, 42), 1, 52 - max(yb, 42), c[1], c[2], c[3]) end c = p.fl[1]; rect(x, max(yb, 52), 1, H - max(yb, 52), c[1], c[2], c[3]) if yb - yt > 3 then local bh = dx > 14 and 2 or 1 c = p.base; rect(x, yb - bh, 1, bh, c[1], c[2], c[3]) end end c = p.stripe for _, z in ipairs({ 1.3, 1.9, 2.6, 3.3 }) do for _, left in ipairs({ true, false }) do local dx = A / z local x = left and floor(CX - dx) or floor(CX + dx - 1) if x >= 0 and x < W then local k = (dx) / A rect(x, floor(CY - B1 * k + 0.5), 1, floor((B1 + B2) * k) - 1, c[1], c[2], c[3]) end end end c = p.seam for _, z in ipairs({ 1.1, 1.8, 2.7 }) do local y = floor(CY + B2 / z + 0.5) local hw = A * (y + 0.5 - CY) / B2 local x0 = max(0, floor(CX - hw + 0.5)) rect(x0, y, min(W, floor(CX + hw + 0.5)) - x0, 1, c[1], c[2], c[3]) end local d1, d2 = A / 2.0, A / 2.8 for x = floor(CX + d2), floor(CX + d1) do local k = (x + 0.5 - CX) / A local ya = floor(CY - B1 * 0.38 * k + 0.5) local yb = floor(CY + B2 * k + 0.5) - 2 local edge = (x == floor(CX + d2) or x == floor(CX + d1)) c = edge and p.frame or p.dr rect(x, ya, 1, yb - ya, c[1], c[2], c[3]) if x == floor(CX + d2) + 1 then px(x, floor(CY + 8 * k + 0.5), p.knob[1], p.knob[2], p.knob[3]) end end BG[p] = gfx.snapshot(0, 0, W, H) end local REC, SHAKE, RUNNER = { 255, 42, 42 }, 1, true function on_settings() local c = cfg.rec or { r = 255, g = 42, b = 42 } REC = { c.r, c.g, c.b } SHAKE = cfg.shake or 1 RUNNER = cfg.runner ~= false end local F = { font = "3x5", cell = true, shadow = { 0, 0, 0 } } local LAMPS = { { 2, 6 }, { 10, 12 }, { 15, 16 }, { 19, 19 } } local DARK = { 22, 16, 8 } local TIME, TSEC = "00:00:00", -1 local BASE = 13 * 60 + 42 local function runner(t, ox, oy, p) local cyc = t // 360 local u = t % 360 - 150 if u < 0 or u >= 30 then return end local dir = (cyc % 2 == 0) and 1 or -1 local x = (dir == 1) and (EX0 - 4 + u * 0.9) or (EX1 + 1 - u * 0.9) x = floor(x + 0.5) + ox local y = EY1 - 10 + oy gfx.clip(EX0 + ox, EY0 + oy, EX1 - EX0 + 1, EY1 - EY0 + 1) local r, g, b = DARK[1], DARK[2], DARK[3] local lean = dir rect(x + 1 + lean, y, 2, 2, r, g, b) rect(x, y + 2, 4, 5, r, g, b) local step = (t // 3) % 2 if step == 0 then rect(x, y + 7, 1, 4, r, g, b); rect(x + 3, y + 7, 1, 3, r, g, b) px(x - 1, y + 3, r, g, b); px(x + 4, y + 4, r, g, b) else rect(x + 1, y + 7, 1, 4, r, g, b); rect(x + 2, y + 7, 1, 4, r, g, b) px(x - 1, y + 4, r, g, b); px(x + 4, y + 3, r, g, b) end gfx.clip() end function render() local t = frame * STEP_HZ // FPS local ox, oy = 0, 0 if SHAKE > 0 then local h = hash32((t // 2) * 7919 + 17) local a = SHAKE if umod(h, 4) == 0 then ox = umod(h >> 4, 2 * a + 1) - a end if umod(h >> 8, 4) == 0 then oy = umod(h >> 12, 2 * a + 1) - a end ox = ox + floor(sin(t * 0.045) * (0.4 + a * 0.5) + 0.5) oy = oy + floor(sin(t * 0.07 + 1) * (0.3 + a * 0.4) + 0.5) if ox > 2 then ox = 2 elseif ox < -2 then ox = -2 end if oy > 2 then oy = 2 elseif oy < -2 then oy = -2 end end local pi = 1 local fl = (t + 61) % 173 if fl == 0 or fl == 1 or fl == 4 then pi = 2 end local p = PALS[pi] gfx.clear(0, 0, 0) if not BG[p] then build_bg(p); gfx.clear(0, 0, 0) end gfx.blit_rgb(BG[p], ox, oy, W, H) for i, r in ipairs(LAMPS) do local lc = p.lamp if umod(hash32(i * 31 + (t // 5) * 977), 41) == 0 then lc = p.lampoff end for y = r[1], r[2] do local dx = 0.612 * (CY - y - 0.5) rect(floor(CX - dx + 0.5) + ox, y + oy, floor(2 * dx + 0.5), 1, lc[1], lc[2], lc[3]) end end if RUNNER then runner(t, ox, oy, p) end local tr = (t % 210) - 170 if tr >= 0 and tr < 22 then local y = H - 1 - tr * 3 blend_rect(0, y, W, 3, 255, 255, 235, 0.22) blend_rect(0, y + 3, W, 1, 255, 255, 235, 0.1) end for i = 1, 3 do local h = hash32(t * 131 + i * 104729) px(umod(h, W), umod(h >> 8, H), 255, 255, 240) end local K = 250 rect(3, 3, 6, 1, K, K, K); rect(3, 3, 1, 6, K, K, K) rect(55, 3, 6, 1, K, K, K); rect(60, 3, 1, 6, K, K, K) rect(3, 60, 6, 1, K, K, K); rect(3, 55, 1, 6, K, K, K) rect(55, 60, 6, 1, K, K, K); rect(60, 55, 1, 6, K, K, K) if (t // 20) % 2 == 0 then rect(7, 6, 3, 3, REC[1], REC[2], REC[3]); rect(6, 7, 5, 1, REC[1], REC[2], REC[3]) end gfx.text(13, 5, "REC", REC[1], REC[2], REC[3], F) rect(47, 5, 10, 5, K, K, K); rect(48, 6, 8, 3, 0, 0, 0); rect(57, 6, 1, 3, K, K, K) rect(49, 7, 2, 1, 80, 230, 90); rect(52, 7, 2, 1, 80, 230, 90) local sec = t // 30 if sec ~= TSEC then TSEC = sec local s = BASE + sec TIME = string.format("%02d:%02d:%02d", (s // 3600) % 100, (s // 60) % 60, s % 60) end gfx.text(14, 52, TIME, K, K, K, F) end