info = { type = "image", title = "Lofi desk", category = "characters", author = "BRRRO", version = "1.0", license = "MIT", desc = "Rainy lofi night, girl at her glowing monitor", api = 33, } local tr = ({ sk = { ["Lamp colour"] = "Farba lampy", ["Rain"] = "Dážď" }, cs = { ["Lamp colour"] = "Barva lampy", ["Rain"] = "Déšť" }, })[lang] or {} local function T(s) return tr[s] or s end settings = { { key = "lamp", label = T("Lamp colour"), type = "color", default = "#FFB86B" }, { key = "rain", label = T("Rain"), type = "bool", default = true }, } local rect, px, blend, blend_rect = gfx.rect, gfx.px, gfx.blend, gfx.blend_rect local floor, sin = math.floor, math.sin local hash32, umod = math.hash32, math.umod local W, H = gfx.W, gfx.H local WALL, DESK_T, DESK_F = { 50, 34, 94 }, { 106, 66, 98 }, { 36, 26, 70 } local FRAME_C, SILL = { 30, 22, 62 }, { 112, 82, 124 } local HAIR, HAIR_D, HAIR_L = { 126, 40, 76 }, { 84, 26, 60 }, { 184, 74, 104 } local CUP, CUP_D = { 232, 218, 236 }, { 150, 134, 170 } local HOOD, HOOD_D, HOOD_L, CHAIR = { 142, 92, 176 }, { 98, 62, 136 }, { 184, 140, 210 }, { 42, 28, 74 } local SKIN = { 244, 196, 176 } local MINT = { 168, 236, 214 } local GX, GY, GW, GH = 4, 6, 18, 20 local SX, SY, SW, SH = 29, 14, 17, 15 local LAMP = { 255, 184, 107 } local function R(x, y, w, h, c) rect(x, y, w, h, c[1], c[2], c[3]) end local function A(x, y, w, h, c, a) blend_rect(x, y, w, h, c[1], c[2], c[3], a) end local BG function on_settings() local c = cfg.lamp or { r = 255, g = 184, b = 107 } LAMP = { c.r, c.g, c.b } BG = nil end local function build_bg() R(0, 0, W, 40, WALL) R(GX - 1, GY - 1, GW + 2, GH + 2, FRAME_C) for y = 0, GH - 1 do local t = y / (GH - 1) rect(GX, GY + y, GW, 1, floor(24 + 40 * t + 0.5), floor(26 + 20 * t + 0.5), floor(92 + 36 * t + 0.5)) end local BOKEH = { { 6, 20, 2, 255, 200, 120 }, { 10, 22, 3, 120, 220, 255 }, { 15, 19, 2, 255, 120, 200 }, { 19, 22, 3, 255, 210, 140 }, { 8, 17, 2, 150, 160, 255 }, { 17, 23, 2, 120, 240, 220 } } for _, b in ipairs(BOKEH) do blend_rect(b[1], b[2], b[3], b[3], b[4], b[5], b[6], 0.45) end rect(GX + 8, GY, 1, GH, FRAME_C[1], FRAME_C[2], FRAME_C[3]) R(GX - 2, GY + GH + 1, GW + 4, 2, SILL) R(GX - 2, GY + GH + 3, GW + 4, 1, { 70, 50, 96 }) R(21, 4, 6, 24, { 176, 92, 144 }); R(22, 4, 1, 24, { 208, 130, 176 }); R(25, 4, 1, 24, { 128, 62, 108 }) R(30, 4, 6, 7, { 214, 120, 170 }); R(31, 5, 4, 3, { 250, 200, 220 }) R(39, 5, 7, 5, { 96, 140, 220 }); R(40, 6, 5, 2, { 170, 210, 250 }) local CAT, CAT_R = { 18, 14, 38 }, { 120, 84, 110 } R(6, 19, 7, 4, CAT); R(7, 18, 5, 1, CAT); R(6, 17, 2, 2, CAT); R(11, 17, 2, 2, CAT) R(5, 23, 9, 5, CAT); R(4, 25, 1, 3, CAT); R(14, 25, 1, 3, CAT) px(7, 17, CAT_R[1], CAT_R[2], CAT_R[3]); px(12, 17, CAT_R[1], CAT_R[2], CAT_R[3]) R(13, 19, 1, 8, CAT_R); R(14, 23, 1, 4, CAT_R) A(22, 8, 30, 30, MINT, 0.04); A(25, 11, 24, 24, MINT, 0.05) R(SX - 2, SY - 2, SW + 4, SH + 4, { 22, 18, 46 }) rect(SX, SY, SW, SH, MINT[1], MINT[2], MINT[3]) R(SX, SY, SW, 2, { 120, 96, 170 }) R(SX + 1, SY + 3, 6, 6, { 236, 140, 190 }); R(SX + 1, SY + 3, 6, 3, { 150, 120, 220 }) R(SX + 9, SY + 4, 7, 1, { 110, 120, 160 }); R(SX + 9, SY + 6, 5, 1, { 150, 160, 190 }); R(SX + 9, SY + 8, 6, 1, { 110, 120, 160 }) R(SX + 1, SY + SH - 3, SW - 2, 1, { 136, 190, 186 }) R(36, 31, 3, 6, { 28, 22, 54 }); R(32, 37, 11, 1, { 28, 22, 54 }) A(1, 24, 18, 16, LAMP, 0.05); A(2, 27, 14, 12, LAMP, 0.06); A(3, 30, 11, 8, LAMP, 0.07) R(8, 29, 1, 9, { 40, 30, 64 }); R(5, 37, 7, 1, { 40, 30, 64 }) R(3, 29, 9, 3, { 232, 150, 90 }); R(4, 32, 7, 1, { 255, 226, 170 }) R(0, 38, W, 6, DESK_T); R(0, 38, W, 1, { 134, 90, 124 }) A(2, 38, 18, 5, LAMP, 0.18); A(25, 38, 20, 4, MINT, 0.14) R(0, 44, W, 20, DESK_F) R(4, 48, 18, 11, { 46, 34, 86 }); R(5, 49, 16, 9, DESK_F); R(12, 52, 2, 1, { 150, 120, 160 }) R(18, 33, 5, 5, { 236, 220, 238 }); R(23, 34, 1, 3, { 236, 220, 238 }); R(19, 34, 3, 1, { 120, 70, 60 }) R(28, 41, 14, 2, { 30, 24, 54 }); R(29, 41, 12, 1, { 78, 70, 120 }) R(38, 34, 26, 30, CHAIR); R(40, 33, 22, 2, CHAIR) R(40, 36, 24, 28, HOOD); R(41, 34, 22, 2, HOOD); R(40, 36, 2, 28, HOOD_L); R(58, 36, 6, 28, HOOD_D) R(35, 38, 7, 5, HOOD); R(35, 38, 2, 5, HOOD_L); R(34, 42, 3, 2, SKIN) R(46, 33, 12, 3, HOOD_D) BG = gfx.snapshot(0, 0, W, H) end local ROWS = { { 48, 8 }, { 46, 12 }, { 45, 14 }, { 44, 16 }, { 44, 16 }, { 44, 16 }, { 44, 16 }, { 44, 16 }, { 44, 16 }, { 44, 17 }, { 44, 17 }, { 44, 17 }, { 44, 17 }, { 44, 17 }, { 44, 17 }, { 45, 15 }, { 46, 13 }, { 47, 11 }, { 48, 9 }, { 49, 7 }, { 50, 5 } } local function head(dy) for i = 1, #ROWS do local r = ROWS[i] rect(r[1], 11 + i + dy, r[2], 1, HAIR[1], HAIR[2], HAIR[3]) end R(54, 16 + dy, 6, 14, HAIR_D) R(44, 17 + dy, 2, 11, HAIR_L); R(46, 14 + dy, 2, 2, HAIR_L) A(44, 17 + dy, 1, 14, MINT, 0.45) R(47, 10 + dy, 10, 1, CUP); R(45, 11 + dy, 2, 3, CUP); R(57, 11 + dy, 2, 3, CUP) R(43, 18 + dy, 3, 7, CUP); R(58, 18 + dy, 3, 7, CUP); R(43, 18 + dy, 1, 7, CUP_D); R(60, 18 + dy, 1, 7, CUP_D) end local function cat_tail(f) local q = f % 190 local pose = 0 if q < 35 then pose = ({ 1, 2, 1, 2, 1, 2, 1 })[q // 5 + 1] end local c = { 18, 14, 38 } if pose == 0 then R(15, 26, 2, 3, c); R(16, 29, 1, 2, c) elseif pose == 1 then R(15, 23, 2, 5, c); R(16, 22, 1, 1, c) else R(15, 20, 2, 8, c); R(16, 19, 1, 1, c); R(14, 19, 1, 1, c) end end local function window_rain(f) gfx.clip(GX, GY, GW, GH) for i = 1, 7 do local h = hash32(i * 0x9E3779B1) local y = (f * 2 + umod(h >> 8, 40)) % 36 - 8 blend_rect(GX + umod(h, GW), GY + y, 1, 5, 200, 210, 255, 0.32) end for i = 1, 4 do local h = hash32(i * 0x85EBCA6B) local yf = (f * (0.1 + 0.03 * (i % 3)) + umod(h >> 8, 200) * 0.1) % (GH + 6) - 3 local x, y0 = GX + 1 + umod(h, GW - 2), floor(yf) local fr = yf - y0 blend(x, GY + y0, 220, 230, 255, 0.7 * (1 - fr)) blend(x, GY + y0 + 1, 220, 230, 255, 0.7 * fr) blend_rect(x, GY + y0 - 3, 1, 3, 200, 210, 255, 0.14) end gfx.clip() end local function steam(f) for w = 0, 1 do for k = 0, 7 do local x = 20.5 + w * 1.6 + 1.6 * sin(f * 0.09 - k * 0.8 + w * 2.1) local ix = floor(x) local fr = x - ix local a = 0.4 * (1 - k / 8) blend(ix, 32 - k, 240, 236, 255, a * (1 - fr)) blend(ix + 1, 32 - k, 240, 236, 255, a * fr) end end end local function screen(f) local x0 = SX + 10 for i = 0, 4 do local hf = 1.5 + 2.2 * (1 + sin(f * 0.17 + i * 1.9)) local h = floor(hf) local bx = SX + 1 + i * 2 + (i > 0 and 7 or 0) bx = x0 + i * 2 - 1 local by = SY + SH - 4 rect(bx, by - h, 1, h, 255, 120, 170) blend(bx, by - h - 1, 255, 120, 170, hf - h) end local pw = (f * 0.04) % 15 local iw = floor(pw) rect(SX + 1, SY + SH - 2, iw, 1, 150, 110, 210) blend(SX + 1 + iw, SY + SH - 2, 150, 110, 210, pw - iw) end local function lights(f) for i = 0, 8 do local x = 28 + i * 4 local y = 2 + floor(1.5 * sin(i * 0.7 + 3) + 0.5) + (i % 2) local a = 0.55 + 0.45 * sin(f * 0.05 + i * 2.1) blend(x, y, LAMP[1], LAMP[2], LAMP[3], a) blend(x, y + 1, LAMP[1], LAMP[2], LAMP[3], a * 0.35) end end function render() if not BG then build_bg() end gfx.blit_rgb(BG, 0, 0, W, H) local f = frame if cfg.rain then window_rain(f) end cat_tail(f) steam(f) screen(f) lights(f) head((f % 23 < 7) and 1 or 0) end