info = { type = "image", title = "Lava lamp", category = "other", author = "BRRRO", version = "1.0", license = "MIT", desc = "Wax blobs rise and sink in a glowing lava lamp", api = 39, } permissions = { "tilt" } local tr = ({ sk = { ["Lamp shape"] = "Tvar lampy", ["rocket"] = "raketa", ["classic"] = "klasická", ["round"] = "okrúhla", ["droplet"] = "kvapka", ["wide"] = "široké", ["no lamp"] = "bez lampy", ["Colour"] = "Farba", ["„random“ = slowly shifting"] = "„náhodne“ = pomaly sa mení", ["original"] = "pôvodná", ["random"] = "náhodne", ["lava"] = "láva", ["turquoise"] = "tyrkysová", ["pink"] = "ružová", ["green"] = "zelená", ["purple"] = "fialová", ["blue"] = "modrá", ["gold"] = "zlatá", ["red"] = "červená", ["Speed"] = "Rýchlosť", ["„random“ = changes by itself"] = "„náhodne“ = mení sa samo", ["slow"] = "pomaly", ["medium"] = "stredne", ["fast"] = "rýchlo", ["Blob count"] = "Počet kvapiek", ["Stars"] = "Hviezdy", ["twinkling behind the lamp"] = "trblieta sa za lampou" }, cs = { ["Lamp shape"] = "Tvar lampy", ["rocket"] = "raketa", ["classic"] = "klasická", ["round"] = "kulatá", ["droplet"] = "kapka", ["wide"] = "široké", ["no lamp"] = "bez lampy", ["Colour"] = "Barva", ["„random“ = slowly shifting"] = "„náhodně“ = pomalu se mění", ["original"] = "původní", ["random"] = "náhodně", ["lava"] = "láva", ["turquoise"] = "tyrkysová", ["pink"] = "růžová", ["green"] = "zelená", ["purple"] = "fialová", ["blue"] = "modrá", ["gold"] = "zlatá", ["red"] = "červená", ["Speed"] = "Rychlost", ["„random“ = changes by itself"] = "„náhodně“ = mění se samo", ["slow"] = "pomalu", ["medium"] = "středně", ["fast"] = "rychle", ["Blob count"] = "Počet kapek", ["Stars"] = "Hvězdy", ["twinkling behind the lamp"] = "třpytí se za lampou" }, })[lang] or {} local function T(s) return tr[s] or s end settings = { { key = "shape", type = "int", default = "rocket", label = T("Lamp shape"), opts = { keys = { "rocket", "classic", "round", "droplet", "wide", "nolamp" }, T("rocket"), T("classic"), T("round"), T("droplet"), T("wide"), T("no lamp") } }, { key = "hue", type = "int", default = "original", label = T("Colour"), hint = T("„random“ = slowly shifting"), opts = { keys = { "original", "random", "lava", "turquoise", "pink", "green", "purple", "blue", "gold", "red" }, T("original"), T("random"), T("lava"), T("turquoise"), T("pink"), T("green"), T("purple"), T("blue"), T("gold"), T("red") } }, { key = "speed", type = "int", default = "slow", label = T("Speed"), hint = T("„random“ = changes by itself"), opts = { keys = { "random", "slow", "medium", "fast" }, T("random"), T("slow"), T("medium"), T("fast") } }, { key = "blobs", type = "int", default = 5, min = 3, max = 6, label = T("Blob count") }, { key = "stars", type = "bool", default = true, label = T("Stars"), hint = T("twinkling behind the lamp") }, } local blend, rect = gfx.blend, gfx.rect local floor, ceil, abs, sin, fmod, sqrt = math.floor, math.ceil, math.abs, math.sin, math.fmod, math.sqrt local unpack, schar, concat = table.unpack, string.char, table.concat local hash32, umod = math.hash32, math.umod local W, H, FPS = gfx.W, gfx.H, gfx.FPS local CX = W // 2 local TAU = 6.28318 local MAX_BLOB = 6 local SHAPE_KEYS = { "ct", "cb", "gt", "gb", "bt", "bb", "cwt", "cwb", "neck", "belly", "foot", "at", "pw", "basew", "bk", "waist", "wat" } local SHAPES = { rocket = "0 6 8 46 47 63 4.2 7.0 7.0 14.0 14.0 1.00 1.00 14.5 1.60 8.5 0.45", classic = "0 7 8 53 54 63 3.0 4.2 4.3 7.3 7.3 1.00 0.85 9.0 1.00 7.3 0", round = "0 2 4 48 49 63 1.6 2.4 2.5 22.5 3.0 0.50 0.50 9.0 1.55 3.5 0.55 ball", droplet = "0 6 7 54 55 63 2.6 3.4 3.6 8.6 6.4 0.72 1.35 8.2 1.05 6.4 0", wide = "0 6 7 53 54 63 3.2 4.6 5.4 10.0 10.0 1.00 1.00 11.0 1.30 10.0 0", nolamp = "0 0 0 63 0 0 0 0 0 0 0 1 1 0 1.75 0 0 none", } local function shape(name) local t, i = {}, 0 for w in (SHAPES[name] or SHAPES.rocket):gmatch("%S+") do i = i + 1 local k = SHAPE_KEYS[i] if k then t[k] = tonumber(w) else t[w] = true end end return t end local PALS = { { lo = { 255, 70, 0 }, hi = { 255, 190, 30 }, lt = { 90, 12, 69 }, lb = { 150, 20, 116 } }, { lo = { 0, 240, 255 }, hi = { 160, 255, 250 }, lt = { 12, 48, 114 }, lb = { 20, 80, 190 } }, { lo = { 255, 0, 130 }, hi = { 255, 60, 170 }, lt = { 66, 6, 105 }, lb = { 110, 10, 176 } }, { lo = { 0, 255, 80 }, hi = { 170, 255, 140 }, lt = { 6, 66, 96 }, lb = { 10, 110, 160 } }, { lo = { 160, 0, 255 }, hi = { 220, 140, 255 }, lt = { 33, 20, 120 }, lb = { 56, 34, 200 } }, { lo = { 0, 100, 255 }, hi = { 130, 210, 255 }, lt = { 57, 12, 103 }, lb = { 96, 20, 172 } }, { lo = { 255, 180, 0 }, hi = { 255, 245, 130 }, lt = { 79, 18, 93 }, lb = { 132, 30, 156 } }, { lo = { 255, 0, 40 }, hi = { 255, 110, 90 }, lt = { 72, 7, 93 }, lb = { 120, 12, 156 } }, } local PAL_AT = { original = 1, lava = 1, turquoise = 2, pink = 3, green = 4, purple = 5, blue = 6, gold = 7, red = 8 } local SPEED_MUL = { 1.1, 2.0, 3.4 } local LVL = { random = 0, slow = 1, medium = 2, fast = 3 } local METAL, METAL_D, METAL_HI = { 60, 10, 205 }, { 36, 0, 125 }, { 196, 206, 236 } local DARK = { 3, 3, 6 } local rng = 0xC2B2AE35 local function rnd() rng = (rng ~ (rng << 13)) & 0xFFFFFFFF rng = rng ~ (rng >> 17) rng = (rng ~ (rng << 5)) & 0xFFFFFFFF return rng end local function frnd(a, b) return a + (b - a) * (umod(rnd(), 1000) / 999.0) end local function mixc(ar, ag, ab, br, bg, bb, t) return floor(ar + (br - ar) * t), floor(ag + (bg - ag) * t), floor(ab + (bb - ab) * t) end local function hsv(r, g, b) local mx = r > g and (r > b and r or b) or (g > b and g or b) local mn = r < g and (r < b and r or b) or (g < b and g or b) local d, h = mx - mn, 0 if d > 0 then if mx == r then h = ((g - b) / d) % 6 elseif mx == g then h = (b - r) / d + 2 else h = (r - g) / d + 4 end end return h, mx > 0 and d / mx or 0, mx end local function from_hsv(h, s, v) h = h % 6 local i = floor(h) local f = h - i local p, q, t = v * (1 - s), v * (1 - s * f), v * (1 - s * (1 - f)) if i == 0 then return v, t, p elseif i == 1 then return q, v, p elseif i == 2 then return p, v, t elseif i == 3 then return p, q, v elseif i == 4 then return t, p, v end return v, p, q end local function mixh(a, b, t) local h1, s1, v1 = hsv(a[1], a[2], a[3]) local h2, s2, v2 = hsv(b[1], b[2], b[3]) if s1 < 0.05 then h1 = h2 elseif s2 < 0.05 then h2 = h1 end local dh = h2 - h1 if dh > 3 then dh = dh - 6 elseif dh < -3 then dh = dh + 6 end local r, g, bb = from_hsv(h1 + dh * t, s1 + (s2 - s1) * t, v1 + (v2 - v1) * t) return { floor(r + 0.5), floor(g + 0.5), floor(bb + 0.5) } end local function amb_lerp(v, n, t) if t <= 0 then return v[1] end if t >= n - 1 then return v[n] end local i = floor(t) return v[i + 1] + (v[i + 2] - v[i + 1]) * (t - i) end local a_cur, a_tgt, a_hold = 1.0, 1.0, 0 local function auto_level(opt, n) if opt > 0 and opt <= n then a_cur, a_tgt, a_hold = opt - 1, opt - 1, 0; return a_cur end if a_hold == 0 then local sp = n - 1 for i = 1, 8 do local t = umod(rnd(), 1000) / 999.0 * sp if abs(t - a_tgt) >= sp * 0.30 then a_tgt = t; break end if i == 8 then a_tgt = sp - a_tgt end end a_hold = FPS * 25 + umod(rnd(), FPS * 60) end a_hold = a_hold - 1 a_cur = a_cur + (a_tgt - a_cur) * 0.0032 return a_cur end local FADE_Q = 16 local p_from, p_to, p_t, p_hold, p_q = 1, 1, 1.0, 0, -1 local cur = PALS[1] local pal_key = 1 local function step_pal(opt) local i = PAL_AT[opt] if i then cur, pal_key = PALS[i], i; p_from, p_to, p_t = i, i, 1.0; return end if p_t >= 1.0 then if p_hold > 0 then p_hold = p_hold - 1; return end p_from = p_to local n repeat n = umod(rnd(), #PALS) + 1 until n ~= p_from p_to, p_t = n, 0.0 end p_t = p_t + 0.007 if p_t >= 1.0 then p_t = 1.0; p_hold = FPS * 30 + umod(rnd(), FPS * 60) end local q = floor(p_t * FADE_Q) local key = p_from * 1000 + p_to * 50 + q if key == pal_key then return end pal_key = key if q >= FADE_Q then cur = PALS[p_to]; return end local f, t, k = PALS[p_from], PALS[p_to], q / FADE_Q cur = { lo = mixh(f.lo, t.lo, k), hi = mixh(f.hi, t.hi, k), lt = mixh(f.lt, t.lt, k), lb = mixh(f.lb, t.lb, k) } end local S = shape("rocket") local HW, LHW = {}, {} local function glass_hw(y) if S.none then return W // 2 - 1 end if S.ball then local r = (S.gb - S.gt) * 0.5 local d = (y - (S.gt + r)) / r local k = 1.0 - d * d return k > 0 and S.belly * sqrt(k) or 0 end local t = (y - S.gt) / (S.gb - S.gt) if t < 0 then t = 0 elseif t > 1 then t = 1 end if t <= S.at then return S.neck + (S.belly - S.neck) * (t / S.at) ^ S.pw end local u = (t - S.at) / (1.0 - S.at) return S.belly + (S.foot - S.belly) * u * u end local function base_hw(y) local t = (y - S.bt) / (S.bb - S.bt) local hw if t < S.wat then hw = S.foot + (S.waist - S.foot) * (t / S.wat) else hw = S.waist + (S.basew - S.waist) * ((t - S.wat) / (1.0 - S.wat)) end if y == S.bb then hw = hw - 1.5 end return hw end local function cap_hw(y) local hw = S.cwt + (S.cwb - S.cwt) * (y - S.ct) / (S.cb - S.ct) if y == S.ct then hw = hw - 1.0 end return hw end local SX0, SW = 0, W local function build_shape() local mx = 0 for y = 0, H - 1 do HW[y] = glass_hw(y) local l = -99 if not S.none then if y <= S.cb then l = cap_hw(y) elseif y < S.gt then l = S.neck elseif y <= S.gb then l = HW[y] else l = base_hw(y) end end LHW[y] = l if l > mx then mx = l end end SX0 = CX - ceil(mx) - 2 if SX0 < 0 then SX0 = 0 end SW = W - 2 * SX0 end local blob = {} for i = 1, MAX_BLOB do blob[i] = { x = 0, y = 0, vy = 0, r = 2, ph = 0, psp = 0.008, temp = 0.5, cx = 0, ox = 0, ovx = 0 } end local function seed() for i = 1, MAX_BLOB do local b = blob[i] b.r = frnd(1.7, 3.0) * S.bk b.y = frnd(S.gt + 5, S.gb - 5) b.vy = frnd(-0.05, 0.05) b.ph = frnd(0, TAU) b.psp = frnd(0.004, 0.013) b.temp = frnd(0.0, 1.0) b.cx = frnd(b.r + 2, W - b.r - 2) b.x, b.ox, b.ovx = b.cx, 0, 0 end end local VY_MAX = 0.12 local lean = 0.0 local function step_blob(b, m) if b.y > S.gb - b.r - 4 then b.temp = b.temp + 0.0045 * m end if b.y < S.gt + b.r + 4 then b.temp = b.temp - 0.0045 * m end if b.temp > 1.0 then b.temp = 1.0 elseif b.temp < 0.0 then b.temp = 0.0 end b.vy = (b.vy + (0.5 - b.temp) * (0.010 / b.r) * m) * 0.988 if b.vy > VY_MAX then b.vy = VY_MAX elseif b.vy < -VY_MAX then b.vy = -VY_MAX end b.y = b.y + b.vy * m if b.y < S.gt + b.r then b.y = S.gt + b.r end if b.y > S.gb - b.r then b.y = S.gb - b.r end b.ph = fmod(b.ph + b.psp * m, TAU) b.ovx = (b.ovx + b.vy * m * lean - b.ox * (0.04 / b.r)) * 0.972 b.ox = b.ox + b.ovx local home, lim if S.none then home = b.cx + 6.0 * sin(b.ph) local x = home + b.ox if x < b.r then x = b.r elseif x > W - 1 - b.r then x = W - 1 - b.r end lim = x else local room = HW[floor(b.y)] - b.r - 1.0 if room < 0 then room = 0 end home = CX + room * 0.8 * sin(b.ph) local x = home + b.ox if x < CX - room then x = CX - room elseif x > CX + room then x = CX + room end lim = x end if lim ~= home + b.ox then b.ox, b.ovx = lim - home, 0 end b.x = lim end local cool, cloud, cloud_up, last_tx = 0, 0.0, 0, 0.0 local KNOCK_GAP = floor(FPS * 0.9) local function tilt_step(n) local t = data.tilt local tx = 0.0 if t and t.ok then tx = t.x local dx = tx - last_tx last_tx = tx local hard = t.bump or t.shake if (t.tap or hard or abs(dx) > 0.2) and cool == 0 then local dir = dx > 0.02 and -1 or (dx < -0.02 and 1 or ((rnd() & 1) == 1 and 1 or -1)) for i = 1, n do local b = blob[i] b.ovx = b.ovx + dir * frnd(0.5, 0.9) / sqrt(b.r) end cool = KNOCK_GAP end if hard then cloud_up = 6 end end if cool > 0 then cool = cool - 1 end lean = lean + (tx - lean) * 0.035 if cloud_up > 0 then cloud_up = cloud_up - 1 cloud = cloud + 0.17 if cloud > 1 then cloud = 1 end elseif cloud > 0 then cloud = cloud - 1.0 / (FPS * 4) if cloud < 0 then cloud = 0 end end end local function span(y, hw, r, g, b) local w = floor(hw + 0.15) local f = hw - w rect(CX - w, y, 2 * w + 1, 1, r, g, b) if f > 0.15 then blend(CX - w - 1, y, r, g, b, f) blend(CX + w + 1, y, r, g, b, f) end end local function edge(y, hw, r, g, b) local w = floor(hw) local f = hw - w if f < 0.85 then blend(CX - w, y, r, g, b, 1.0 - f) blend(CX + w, y, r, g, b, 1.0 - f) end if f > 0.15 then blend(CX - w - 1, y, r, g, b, f) blend(CX + w + 1, y, r, g, b, f) end end local function metal_row(y, hw, shine) local w = floor(hw) span(y, hw, METAL_D[1], METAL_D[2], METAL_D[3]) local l = CX - w + (w >= 6 and 2 or 1) rect(l, y, CX + floor(w * 0.35) - l + 1, 1, METAL[1], METAL[2], METAL[3]) if shine then rect(CX - w + floor(w * 0.35) + 1, y, w >= 10 and 2 or 1, 1, METAL_HI[1], METAL_HI[2], METAL_HI[3]) end end local function liquid(y) local lt, lb = cur.lt, cur.lb return mixc(lt[1], lt[2], lt[3], lb[1], lb[2], lb[3], (y - S.gt) / (S.gb - S.gt)) end local BANDS, LEVELS = 31, 8 local PAL = nil local function build_pal() local lo, hi = cur.lo, cur.hi local P = { 0, 0, 0 } for band = 0, BANDS - 1 do local vt = (band + 0.5) / BANDS local cr, cg, cb = mixc(hi[1], hi[2], hi[3], lo[1], lo[2], lo[3], vt) local br, bg, bb = DARK[1], DARK[2], DARK[3] if not S.none then br, bg, bb = liquid(S.gt + vt * (S.gb - S.gt)) end for l = 1, LEVELS do local a = l / LEVELS local i = (band * LEVELS + l) * 3 P[i + 1], P[i + 2], P[i + 3] = mixc(br, bg, bb, cr, cg, cb, 0.15 + 0.85 * a * sqrt(a)) end end PAL = table.pack(unpack(P, 1, #P)) end local SNAP, snap_key = nil, nil local function build_scene() gfx.clear(DARK[1], DARK[2], DARK[3]) if not S.none then local lo = cur.lo for y = S.gt, S.gb do span(y, HW[y], liquid(y)) end for y = S.gt, S.gb do edge(y, HW[y], lo[1], lo[2], lo[3]) end for y = S.bt, S.bb do metal_row(y, base_hw(y), y > S.bt and y < S.bb and y ~= S.bt + floor((S.bb - S.bt) * S.wat + 0.5)) end for y = S.ct, S.cb do metal_row(y, cap_hw(y), y > S.ct and y < S.cb) end local w = floor(base_hw(S.bt)) gfx.blend_rect(CX - w, S.bt, 2 * w + 1, 1, lo[1], lo[2], lo[3], 0.45) w = floor(cap_hw(S.cb)) gfx.blend_rect(CX - w, S.cb, 2 * w + 1, 1, lo[1], lo[2], lo[3], 0.3) end SNAP = nil if not S.none then SNAP = gfx.snapshot(SX0, 0, SW, H) end build_pal() end local fld, rows, row = {}, {}, {} local bx0, bx1 = {}, {} local BX, BY, BR2, BE, BRR = {}, {}, {}, {}, {} local sh_x, sh_y, sh_on = {}, {}, {} local srep = string.rep local POOL = { 4.0, 4.0, 2.0, 0.62, 0.2 } local WAVE = {} local wp1, wp2 = 0.0, 0.0 local function draw_lava(n) local lamp = not S.none local x0, y0, x1, y1 = 1e9, 1e9, -1e9, -1e9 local gb = S.gb local py0 = gb - #POOL + 1 if lamp then local hw = HW[gb] x0, y0, x1, y1 = CX - hw, py0, CX + hw, gb end for i = 1, n do local b = blob[i] local r = b.r * (0.93 + 0.12 * b.temp) local e = 1.0 + 0.25 * abs(b.vy) / VY_MAX local rr = r * 1.5 + 1.0 BX[i], BY[i], BR2[i], BE[i], BRR[i] = b.x, b.y, r * r, e, rr local rx, ry = rr / e, rr * e if b.x - rx < x0 then x0 = b.x - rx end if b.x + rx > x1 then x1 = b.x + rx end if b.y - ry < y0 then y0 = b.y - ry end if b.y + ry > y1 then y1 = b.y + ry end sh_x[i] = floor(b.x - r * 0.45 / e + 0.5) sh_y[i] = r >= 3.0 and floor(b.y - r * 0.45 * e + 0.5) or -1 sh_on[i] = false end x0, y0, x1, y1 = floor(x0), floor(y0), ceil(x1), ceil(y1) if x0 < 0 then x0 = 0 end if y0 < S.gt then y0 = S.gt end if x1 > W - 1 then x1 = W - 1 end if y1 > gb then y1 = gb end if x1 < x0 or y1 < y0 then return end local bw, bh = x1 - x0 + 1, y1 - y0 + 1 if lamp then for x = x0, x1 do WAVE[x + 1] = 0.6 * sin(x * 0.42 + wp1) + 0.4 * sin(x * 0.17 - wp2) end end local thr = 0.90 + 0.55 * cloud local k = LEVELS / 0.50 local gh = gb - S.gt local ZB = srep("\0", bw) for y = y0, y1 do local a, e = 1e9, -1e9 for i = 1, n do local dy = (y - BY[i]) / BE[i] local rr = BRR[i] local h = rr * rr - dy * dy if h > 0 then h = sqrt(h) / BE[i] local ia, ie = floor(BX[i] - h), ceil(BX[i] + h) bx0[i], bx1[i] = ia, ie if ia < a then a = ia end if ie > e then e = ie end else bx0[i], bx1[i] = 1e9, -1e9 end end local pool = lamp and y >= py0 if pool then a, e = x0, x1 end if a < x0 then a = x0 end if e > x1 then e = x1 end if lamp and a <= e then local hw = HW[y] - 1 local ga, ge = ceil(CX - hw), floor(CX + hw) if a < ga then a = ga end if e > ge then e = ge end end if a > e then rows[y - y0 + 1] = ZB else for x = a + 1, e + 1 do fld[x] = 0 end for i = 1, n do local ia, ie = bx0[i], bx1[i] if ia < a then ia = a end if ie > e then ie = e end if ia <= ie then local be = BE[i] local r2, bx, dy, e2 = BR2[i], BX[i], (y - BY[i]) / be, be * be local dy2 = dy * dy + 0.9 for x = ia, ie do local dx = x - bx fld[x + 1] = fld[x + 1] + r2 / (dx * dx * e2 + dy2) end end end if pool then local j = gb - y + 1 local pv = POOL[j] if j >= 4 then local amp = j == 4 and 0.35 or 0.2 for x = a + 1, e + 1 do fld[x] = fld[x] + pv + amp * WAVE[x] end else for x = a + 1, e + 1 do fld[x] = fld[x] + pv end end end local band = floor((y - S.gt) * BANDS / gh) if band < 0 then band = 0 elseif band > BANDS - 1 then band = BANDS - 1 end local base = band * LEVELS local j = 1 for x = a + 1, e + 1 do local f = fld[x] if f >= thr then local l = ceil((f - thr) * k) if l < 1 then l = 1 elseif l > LEVELS then l = LEVELS end row[j] = base + l else row[j] = 0 end j = j + 1 end rows[y - y0 + 1] = srep("\0", a - x0) .. schar(unpack(row, 1, e - a + 1)) .. srep("\0", x1 - e) for i = 1, n do local hx = sh_x[i] if sh_y[i] == y and hx >= a and hx <= e and fld[hx + 1] >= thr + 0.6 then sh_on[i] = true end end end end gfx.blit_indexed(concat(rows, "", 1, bh), PAL, x0, y0, bw, bh, bw, bh, true) for i = 1, n do if sh_on[i] then blend(sh_x[i], sh_y[i], 255, 225, 240, 0.75) end end end local N_STAR = 14 local function draw_stars(f) local lo = cur.lo for i = 1, N_STAR do local h = hash32(i * 0x9E3779B1) local x, y = umod(h, W), umod(h >> 8, H) local cross = umod(h >> 12, 3) == 0 if abs(x - CX) > LHW[y] + (cross and 2 or 1) then local s = sin(fmod(f * (0.03 + umod(h >> 4, 40) / 1000.0) + umod(h >> 16, 628) / 100.0, TAU)) local kk = 0.5 + 0.5 * s local r, g, b = 90, 120, 255 if (i & 1) == 0 then r, g, b = lo[1], lo[2], lo[3] end blend(x, y, r, g, b, 0.35 + 0.65 * kk) if cross and kk > 0.7 then local a = (kk - 0.7) * 1.6 blend(x - 1, y, r, g, b, a); blend(x + 1, y, r, g, b, a) blend(x, y - 1, r, g, b, a); blend(x, y + 1, r, g, b, a) end end end end local function blob_n() local n = cfg.blobs or 5 if n > MAX_BLOB then n = MAX_BLOB elseif n < 1 then n = 1 end return n end function on_settings() S = shape(cfg.shape) build_shape() seed() snap_key = nil end function update() step_pal(cfg.hue or "original") local m = amb_lerp(SPEED_MUL, 3, auto_level(LVL[cfg.speed] or 1, 3)) local n = blob_n() tilt_step(n) for i = 1, n do step_blob(blob[i], m) end wp1 = fmod(wp1 + 0.021 * m, TAU) wp2 = fmod(wp2 + 0.013 * m, TAU) end function render() if snap_key ~= pal_key then build_scene() snap_key = pal_key else gfx.clear(DARK[1], DARK[2], DARK[3]) if SNAP then gfx.blit_rgb(SNAP, SX0, 0, SW, H) end end if cfg.stars ~= false then draw_stars(frame % 54000) end draw_lava(blob_n()) end