info = { type = "image", title = "Plasma ball", category = "other", author = "BRRRO", version = "1.0", license = "MIT", desc = "Discharges in a plasma globe", api = 33, } local px, blend, rect = gfx.px, gfx.blend, gfx.rect local floor, ceil, sqrt, sin, cos, fmod = math.floor, math.ceil, math.sqrt, math.sin, math.cos, math.fmod local PI2 = 2 * math.pi local W, H = gfx.W, gfx.H local FPS = gfx.FPS local CX, CY = W // 2, H // 2 - 5 local R = W // 2 - 8 local MAX_ARC, STEPS = 9, 18 local tr = ({ sk = { ["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á", ["Intensity"] = "Intenzita", ["„random“ = changes by itself"] = "„náhodne“ = mení sa samo", ["weak"] = "slabo", ["medium"] = "stredne", ["intense"] = "silno", ["Glass and base"] = "Sklo a podstavec", ["off = discharges only"] = "vypnuté = len vybíjanie", ["Hand touch"] = "Dotyk ruky", ["a finger touches the glass now and then"] = "občas sa prsta dotkne skla" }, cs = { ["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á", ["Intensity"] = "Intenzita", ["„random“ = changes by itself"] = "„náhodně“ = mění se samo", ["weak"] = "slabě", ["medium"] = "středně", ["intense"] = "silně", ["Glass and base"] = "Sklo a podstavec", ["off = discharges only"] = "vypnuto = pouze vybíjení", ["Hand touch"] = "Dotyk ruky", ["a finger touches the glass now and then"] = "občas se prstu dotkne sklo" }, })[lang] or {} local function T(s) return tr[s] or s end settings = { { 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 = "power", type = "int", default = "medium", label = T("Intensity"), hint = T("„random“ = changes by itself"), opts = { keys = { "random", "weak", "medium", "intense" }, T("random"), T("weak"), T("medium"), T("intense") } }, { key = "glass", type = "bool", default = true, label = T("Glass and base"), hint = T("off = discharges only") }, { key = "touch", type = "bool", default = true, label = T("Hand touch"), hint = T("a finger touches the glass now and then") }, } local ARCS = { 4, 6, MAX_ARC } local WOBBLE = { 0.26, 0.36, 0.52 } local LIFE = { 1.00, 0.75, 0.50 } local ARC_LVL = { 185, 220, 255 } local SPOT_LVL = 255 local CORE_LVL = 255 local GLASS_LVL, HILITE_LVL = 148, 235 local INSIDE_LVL = 84 local GLASS_HUE = { 210, 226, 255 } local WHITE = { 255, 255, 255 } local rng = 0x7A11B0C5 local function rnd() rng = (rng ~ (rng << 13)) & 0xFFFFFFFF rng = rng ~ (rng >> 17) rng = (rng ~ (rng << 5)) & 0xFFFFFFFF return rng end local umod = math.umod local function frnd(a, b) return a + (b - a) * (umod(rnd(), 1000) / 999.0) end local SP_HOLD_MIN, SP_HOLD_SPAN = FPS * 25, FPS * 60 local a_cur, a_tgt, a_hold = 1.0, 1.0, 0 local LVL = { random = 0, weak = 1, medium = 2, intense = 3 } 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 local d = t - a_tgt if d < 0 then d = -d end if d >= sp * 0.30 then a_tgt = t; break end if i == 8 then a_tgt = sp - a_tgt end end a_hold = SP_HOLD_MIN + umod(rnd(), SP_HOLD_SPAN) end a_hold = a_hold - 1 a_cur = a_cur + (a_tgt - a_cur) * (0.096 / FPS) return a_cur 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 PAL_N = 8 local PALS = { { lo = { 255, 105, 25 }, hi = { 255, 205, 70 } }, { lo = { 40, 215, 255 }, hi = { 150, 255, 235 } }, { lo = { 255, 85, 180 }, hi = { 255, 175, 230 } }, { lo = { 60, 235, 90 }, hi = { 180, 255, 140 } }, { lo = { 150, 80, 255 }, hi = { 215, 170, 255 } }, { lo = { 45, 120, 255 }, hi = { 130, 205, 255 } }, { lo = { 255, 170, 20 }, hi = { 255, 235, 120 } }, { lo = { 255, 55, 45 }, hi = { 255, 150, 90 } }, } local PAL_AT = { lava = 1, turquoise = 2, pink = 3, green = 4, purple = 5, blue = 6, gold = 7, red = 8 } local OWN_LO, OWN_HI = { 175, 70, 255 }, { 255, 165, 250 } local LO, HI = { 175, 70, 255 }, { 255, 165, 250 } local A_FADE = 0.21 / FPS local A_HOLD_MIN, A_HOLD_SPAN = FPS * 30, FPS * 60 local p_from, p_to, p_t, p_hold = 1, 1, 1.0, 0 local function set_pal(lr, lg, lb, hr, hg, hb) LO[1], LO[2], LO[3] = lr, lg, lb HI[1], HI[2], HI[3] = hr, hg, hb end local function step_pal(opt) if opt == "original" then set_pal(OWN_LO[1], OWN_LO[2], OWN_LO[3], OWN_HI[1], OWN_HI[2], OWN_HI[3]) return end local fixed = PAL_AT[opt] if fixed then local p = PALS[fixed] set_pal(p.lo[1], p.lo[2], p.lo[3], p.hi[1], p.hi[2], p.hi[3]) return end if p_t >= 1.0 then if p_hold > 0 then p_hold = p_hold - 1 local p = PALS[p_to] set_pal(p.lo[1], p.lo[2], p.lo[3], p.hi[1], p.hi[2], p.hi[3]) return end p_from = p_to local n repeat n = umod(rnd(), PAL_N) + 1 until n ~= p_from p_to, p_t = n, 0.0 end p_t = p_t + A_FADE if p_t > 1.0 then p_t = 1.0; p_hold = A_HOLD_MIN + umod(rnd(), A_HOLD_SPAN) end local f, t = PALS[p_from], PALS[p_to] set_pal(f.lo[1] + (t.lo[1] - f.lo[1]) * p_t, f.lo[2] + (t.lo[2] - f.lo[2]) * p_t, f.lo[3] + (t.lo[3] - f.lo[3]) * p_t, f.hi[1] + (t.hi[1] - f.hi[1]) * p_t, f.hi[2] + (t.hi[2] - f.hi[2]) * p_t, f.hi[3] + (t.hi[3] - f.hi[3]) * p_t) end local function tint(c, lvl) local r, g, b = c[1], c[2], c[3] local m = r if g > m then m = g end if b > m then m = b end local k = lvl / m return floor(r * k), floor(g * k), floor(b * k) end local TH = {} local SPOT_HUE = { 255, 210, 250 } local function build_thread() for i = 1, STEPS do local t = i / STEPS local r, g, b if t <= 0.35 then local f = t / 0.35 r = 255 + (HI[1] - 255) * f g = 255 + (HI[2] - 255) * f b = 255 + (HI[3] - 255) * f else local f = (t - 0.35) / 0.65 r = HI[1] + (LO[1] - HI[1]) * f g = HI[2] + (LO[2] - HI[2]) * f b = HI[3] + (LO[3] - HI[3]) * f end local m = r if g > m then m = g end if b > m then m = b end local k = 255 / m local o = (i - 1) * 3 TH[o + 1], TH[o + 2], TH[o + 3] = r * k, g * k, b * k end local m = 0 for j = 1, 3 do local v = HI[j] + (255 - HI[j]) * 0.45 SPOT_HUE[j] = v if v > m then m = v end end local k = 255 / m SPOT_HUE[1], SPOT_HUE[2], SPOT_HUE[3] = SPOT_HUE[1] * k, SPOT_HUE[2] * k, SPOT_HUE[3] * k end local EL, EH, EK = 0.36, 0.64, 1.0 / 0.28 local A_MIN = 0.14 local function dot(x, y, r, g, b, a) local xi, yi = floor(x), floor(y) local fx, fy = x - xi, y - yi local wx0, wx1, wy0, wy1 if fx <= EL then wx0, wx1 = a, 0.0 elseif fx >= EH then wx0, wx1 = 0.0, a else local t = (fx - EL) * EK; wx0, wx1 = a * sqrt(1.0 - t), a * sqrt(t) end if fy <= EL then wy0, wy1 = 1.0, 0.0 elseif fy >= EH then wy0, wy1 = 0.0, 1.0 else local t = (fy - EL) * EK; wy0, wy1 = sqrt(1.0 - t), sqrt(t) end if wy0 > 0.0 then if wx0 * wy0 >= A_MIN then blend(xi, yi, r, g, b, wx0 * wy0) end if wx1 * wy0 >= A_MIN then blend(xi + 1, yi, r, g, b, wx1 * wy0) end end if wy1 > 0.0 then if wx0 * wy1 >= A_MIN then blend(xi, yi + 1, r, g, b, wx0 * wy1) end if wx1 * wy1 >= A_MIN then blend(xi + 1, yi + 1, r, g, b, wx1 * wy1) end end end local A_ANG, A_TGT, A_PH, A_PSP = {}, {}, {}, {} local A_BRI, A_BRT, A_LIFE = {}, {}, {} local A_B1, A_B2, A_BT, A_HV = {}, {}, {}, {} local LIFE_MIN, LIFE_SPAN = floor(FPS * 0.5), floor(FPS * 2.5) local K_ANG, K_BRI = 1.2 / FPS, 3.0 / FPS local K_TOUCH = 5.4 / FPS local PULSE = 6.6 / FPS local T_APP, T_HOLD, T_OUT, T_FIRST = FPS // 2, FPS * 4, FPS // 2, FPS * 3 local touch_start, touch_ang, touch_r, touching = T_FIRST, -0.8, nil, false local bscale = 1.0 local function new_look(i) local nb = umod(rnd(), 3) local d = frnd(0.22, 0.45) if umod(rnd(), 2) == 0 then d = -d end A_B1[i] = nb >= 1 and d or 0 A_B2[i] = nb >= 2 and -d * frnd(0.7, 1.1) or 0 A_BT[i] = frnd(0.45, 0.68) A_HV[i] = umod(rnd(), 3) end local function pick_touch() touch_ang = (umod(rnd(), 2) == 0 and 0.86 or 2.28) + frnd(-0.15, 0.15) end local function seed() for i = 1, MAX_ARC do A_ANG[i] = frnd(0, PI2) A_TGT[i] = A_ANG[i] A_PH[i] = frnd(0, PI2) A_PSP[i] = frnd(3.0, 7.8) / FPS A_BRI[i] = frnd(0.40, 1.00) A_BRT[i] = frnd(0.50, 1.00) A_LIFE[i] = LIFE_MIN + umod(rnd(), LIFE_SPAN) new_look(i) end pick_touch() end local function step_arc(i, lifek) A_PH[i] = fmod(A_PH[i] + A_PSP[i], PI2) if touching then local d = fmod(touch_ang + (i - 5) * 0.03 - A_ANG[i] + PI2 * 8 + PI2 / 2, PI2) - PI2 / 2 A_ANG[i] = A_ANG[i] + d * K_TOUCH A_BRI[i] = A_BRI[i] + (1.0 - A_BRI[i]) * K_BRI return end if A_LIFE[i] <= 0 then A_TGT[i] = frnd(0, PI2) A_BRT[i] = frnd(0.45, 1.00) A_LIFE[i] = floor((LIFE_MIN + umod(rnd(), LIFE_SPAN)) * lifek) if umod(rnd(), 3) == 0 then A_ANG[i] = A_TGT[i] end new_look(i) else A_LIFE[i] = A_LIFE[i] - 1 end A_ANG[i] = A_ANG[i] + (A_TGT[i] - A_ANG[i]) * K_ANG A_BRI[i] = A_BRI[i] + (A_BRT[i] - A_BRI[i]) * K_BRI end local function step_touch() if cfg.touch == false or cfg.glass == false then touching, touch_r = false, nil; return end local u = frame - touch_start if u >= T_APP + T_HOLD + T_OUT then touch_start = frame + FPS * 18 + umod(rnd(), FPS * 20) pick_touch() u = frame - touch_start end local was = touching touching = u >= T_APP and u < T_APP + T_HOLD if u < 0 then touch_r = nil elseif u < T_APP then local e = 1 - u / T_APP; touch_r = R + 1 + 17 * e * e elseif u < T_APP + T_HOLD then touch_r = R + 1 else local e = (u - T_APP - T_HOLD) / T_OUT; touch_r = R + 1 + 17 * e * e end if was and not touching then for i = 1, MAX_ARC do A_TGT[i] = frnd(0, PI2) A_LIFE[i] = LIFE_MIN + umod(rnd(), LIFE_SPAN) if umod(rnd(), 3) == 0 then A_ANG[i] = A_TGT[i] end new_look(i) end end bscale = bscale + ((touching and 0 or 1) - bscale) * 0.15 end local function draw_spot(x, y, k, s) s = s or 1 local sr, sg, sb = tint(SPOT_HUE, SPOT_LVL) local xi, yi = floor(x), floor(y) local fx, fy = x - xi, y - yi local c0, c1 = 0.8 * s, 1.6 * s local m = s > 1 and 3 or 2 for dy = -m, m do for dx = -m, m do local ax, ay = dx - fx, dy - fy local d = sqrt(ax * ax + ay * ay) if d <= c0 + c1 then local a = (d <= c0 and 1.0 or (1.0 - (d - c0) / c1) * 0.60) * k if a >= A_MIN then blend(xi + dx, yi + dy, sr, sg, sb, a) end end end end end local function stroke(X, Y, j0, last, touch, k, vr, vg, vb, m, gr, gg, gb, ga0, step, amul) local x0, y0 = X[j0 + 1], Y[j0 + 1] for j = j0 + 1, last do local x1, y1 = X[j + 1], Y[j + 1] local o = (j - 1) * 3 local tj = j / STEPS local cr, cg, cb = TH[o + 1], TH[o + 2], TH[o + 3] cr, cg, cb = (cr + (vr - cr) * m) * k, (cg + (vg - cg) * m) * k, (cb + (vb - cb) * m) * k local ga = ga0 > 0 and (ga0 - 0.16 * tj) * k or 0 local fade = (not touch) and j > last - 2 local dx, dy = x1 - x0, y1 - y0 local len = sqrt(dx * dx + dy * dy) local n = floor(len * step) + 1 local ux, uy = dx / n, dy / n local nx, ny = 0.0, 0.0 if len > 0.01 then nx, ny = -dy / len * 1.25, dx / len * 1.25 end for s = 1, n do local xx, yy = x0 + ux * s, y0 + uy * s local a = amul if fade then a = a * (1.0 - 0.8 * ((j - last + 1) + s / n) / 2.0) end dot(xx, yy, cr, cg, cb, a) if ga > 0 and (s & 1) == 1 and ga * a >= A_MIN then blend(floor(xx - nx + 0.5), floor(yy - ny + 0.5), gr, gg, gb, ga * a) blend(floor(xx + nx + 0.5), floor(yy + ny + 0.5), gr, gg, gb, ga * a) end end x0, y0 = x1, y1 end return x0, y0 end local AX, AY, AN, BX, BY = {}, {}, {}, {}, {} local function draw_arc(i, wob) local bri = A_BRI[i] local lvl = bri < 0.52 and ARC_LVL[1] or (bri < 0.76 and ARC_LVL[2] or ARC_LVL[3]) local k = lvl / 255.0 local reach = 0.70 + 0.42 * bri if reach > 1.0 then reach = 1.0 end local last = floor(STEPS * reach + 0.5) if last < 5 then last = 5 end local touch = last >= STEPS local gr, gg, gb = tint(LO, lvl) local vr, vg, vb, m = 255, 255, 255, 0 if A_HV[i] == 1 then vr, vg, vb, m = 215, 225, 255, 0.35 elseif A_HV[i] == 2 then vr, vg, vb = tint(LO, 255); m = 0.40 end local ang, ph = A_ANG[i], A_PH[i] for j = 0, last do local t = j / STEPS local rr = 2.0 + t * (R - 2.0) local an = ang + wob * t * t * (sin(ph + t * 5.2) + 0.5 * sin(ph * 1.7 + t * 9.1)) AN[j + 1] = an AX[j + 1] = CX + rr * cos(an) AY[j + 1] = CY + rr * sin(an) end local ex, ey = stroke(AX, AY, 0, last, touch, k, vr, vg, vb, m, gr, gg, gb, 0.34, 1.25, 1.0) if touch then draw_spot(ex, ey, k) end local bt = A_BT[i] local jb = floor(bt * STEPS) if last <= jb + 3 then return end for b = 1, 2 do local d = (b == 1 and A_B1[i] or A_B2[i]) * bscale if d > 0.02 or d < -0.02 then for j = jb, last do local t = j / STEPS local s = (t - bt) / (1 - bt) if s < 0 then s = 0 end local rr = 2.0 + t * (R - 2.0) local an = AN[j + 1] + d * s + 0.10 * s * sin(ph * 1.9 + t * 11.0 + b) BX[j + 1] = CX + rr * cos(an) BY[j + 1] = CY + rr * sin(an) end local bx, by = stroke(BX, BY, jb, last, touch, k, vr, vg, vb, m, gr, gg, gb, 0, 1.0, 0.8) if touch then draw_spot(bx, by, k * 0.6) end end end end local N_STAR = 14 local function draw_stars(f) for i = 1, N_STAR do local h = math.hash32(i * 0x9E3779B1) local x, y = umod(h, W), umod(h >> 8, H) local k = 0.5 + 0.5 * sin(fmod(f * (0.03 + umod(h >> 4, 40) / 1000.0) + umod(h >> 16, 628) / 100.0, PI2)) local r, g, b = 90, 120, 255 if (i & 1) == 0 then r, g, b = tint(LO, 255) end blend(x, y, r, g, b, 0.35 + 0.65 * k) if umod(h >> 12, 3) == 0 and k > 0.7 then local a = (k - 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 local function draw_core() local pr, pg, pb = tint(HI, CORE_LVL) local rout = 4.0 + 0.9 * sin(fmod(frame * PULSE, PI2)) for dy = -5, 5 do for dx = -5, 5 do local d = sqrt(dx * dx + dy * dy) if d <= 1.6 then px(CX + dx, CY + dy, 255, 255, 255) elseif d <= rout then local a = (1.0 - (d - 1.6) / (rout - 1.6)) * 0.85 if a >= A_MIN then blend(CX + dx, CY + dy, pr, pg, pb, a) end end end end end local function draw_inside() local ir, ig, ib = tint(LO, INSIDE_LVL) for y = CY - R, CY + R do local dy = y - CY local w = floor(sqrt(R * R - dy * dy)) rect(CX - w, y, 2 * w + 1, 1, ir, ig, ib) end end local STATIC = nil local function draw_glass() local gr, gg, gb = tint(GLASS_HUE, GLASS_LVL) for x = CX - R, CX + R do local d = R * R - (x - CX) * (x - CX) if d >= 0 then d = sqrt(d) px(x, floor(CY - d + 0.5), gr, gg, gb) px(x, floor(CY + d + 0.5), gr, gg, gb) end end for y = CY - R, CY + R do local d = R * R - (y - CY) * (y - CY) if d >= 0 then d = sqrt(d) px(floor(CX - d + 0.5), y, gr, gg, gb) px(floor(CX + d + 0.5), y, gr, gg, gb) end end local hr, hg, hb = tint(WHITE, HILITE_LVL) for i = 0, 15 do local an = 3.55 + i * 0.048 px(floor(CX + (R - 2) * cos(an) + 0.5), floor(CY + (R - 2) * sin(an) + 0.5), hr, hg, hb) end end local METAL, METAL_D, METAL_HI = { 64, 46, 190 }, { 36, 20, 120 }, { 200, 206, 240 } local function span(y, hw, r, g, b) local w = floor(hw) local f = hw - w rect(CX - w, y, 2 * w + 1, 1, r, g, b) if f > 0.03 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 draw_base() local top, bot = CY + R, H - 1 metal_row(top, 6.5, false) metal_row(top + 1, 7.0, true) for y = top + 2, bot do local t = (y - top - 2) / (bot - top - 2) local hw = 5.5 + 8.0 * t ^ 1.6 if y == bot then hw = hw - 1.5 end metal_row(y, hw, y > top + 2 and y < bot) end end local function poly(P, n, r, g, b) local ymin, ymax = 1e9, -1e9 for i = 1, n do local y = P[2 * i] if y < ymin then ymin = y end if y > ymax then ymax = y end end if ymin < 0 then ymin = 0 end if ymax > H then ymax = H end for y = floor(ymin), ceil(ymax) - 1 do local yc, lo, hi = y + 0.5, 1e9, -1e9 for i = 1, n do local j = i % n + 1 local x1, y1, x2, y2 = P[2 * i - 1], P[2 * i], P[2 * j - 1], P[2 * j] if (y1 <= yc) ~= (y2 <= yc) then local x = x1 + (yc - y1) * (x2 - x1) / (y2 - y1) if x < lo then lo = x end if x > hi then hi = x end end end local xs, xe = floor(lo + 0.5), floor(hi + 0.5) if xe > xs then rect(xs, y, xe - xs, 1, r, g, b) end end end local function seg(x0, y0, x1, y1, r, g, b) local n = floor(math.max(math.abs(x1 - x0), math.abs(y1 - y0)) + 0.5) if n < 1 then n = 1 end for i = 0, n do local t = i / n px(floor(x0 + (x1 - x0) * t + 0.5), floor(y0 + (y1 - y0) * t + 0.5), r, g, b) end end local SKIN, SKIN_D, SKIN_L = { 222, 168, 134 }, { 176, 118, 92 }, { 246, 206, 180 } local function draw_finger(rt) local ux, uy = cos(touch_ang), sin(touch_ang) local nx, ny = -uy, ux if ny < 0 then nx, ny = -nx, -ny end local tx, ty = CX + ux * rt, CY + uy * rt local function at(a, b) return tx + ux * a + nx * b, ty + uy * a + ny * b end local P = {} local function quad(...) local v, n = { ... }, select("#", ...) // 2 for i = 1, n do P[2 * i - 1], P[2 * i] = at(v[2 * i - 1], v[2 * i]) end for i = 2 * n + 1, #P do P[i] = nil end poly(P, n, SKIN[1], SKIN[2], SKIN[3]) end quad(0, 0, 1.6, 2.7, 11, 3.0, 11, -3.0, 1.6, -2.7) quad(8, 3.0, 13, 7.5, 34, 8.5, 34, -8.0, 13, -6.5, 8, -3.0) local x0, y0, x1, y1 x0, y0 = at(2, 2.1); x1, y1 = at(9, 2.3); seg(x0, y0, x1, y1, SKIN_D[1], SKIN_D[2], SKIN_D[3]) x0, y0 = at(12, 7.0); x1, y1 = at(34, 8.0); seg(x0, y0, x1, y1, SKIN_D[1], SKIN_D[2], SKIN_D[3]) x0, y0 = at(12, -5.8); x1, y1 = at(12, 5.5); seg(x0, y0, x1, y1, SKIN_L[1], SKIN_L[2], SKIN_L[3]) x0, y0 = at(1.8, -1.3); x1, y1 = at(3.6, -1.3); seg(x0, y0, x1, y1, 248, 216, 204) if touching then local r, g, b = tint(HI, 255) blend(floor(tx + ux * 0.8 + 0.5), floor(ty + uy * 0.8 + 0.5), r, g, b, 0.75) blend(floor(tx + ux * 2.0 + 0.5), floor(ty + uy * 2.0 + 0.5), r, g, b, 0.40) end end local N, WOB, LIFEK = ARCS[2], WOBBLE[2], LIFE[2] function on_settings() STATIC = nil seed() touch_start, touching, touch_r = (frame or 0) + T_FIRST, false, nil step_pal(cfg.hue or "original") build_thread() end function update() step_pal(cfg.hue or "original") build_thread() local lv = auto_level(LVL[cfg.power] or 2, 3) WOB = amb_lerp(WOBBLE, 3, lv) LIFEK = amb_lerp(LIFE, 3, lv) N = floor(amb_lerp(ARCS, 3, lv) + 0.5) step_touch() for i = 1, N do step_arc(i, LIFEK) end end function render() gfx.clear(0, 0, 0) if cfg.glass == false then draw_stars(frame) for i = 1, N do draw_arc(i, WOB) end draw_core() return end if not STATIC then draw_glass() draw_base() STATIC = gfx.snapshot(0, 0, W, H) gfx.clear(0, 0, 0) end draw_stars(frame) draw_inside() gfx.blit_rgb(STATIC, 0, 0, W, H, 0, 0, 0) for i = 1, N do draw_arc(i, WOB) end draw_core() if touching then draw_spot(CX + R * cos(touch_ang), CY + R * sin(touch_ang), 1.0, 1.5) end if touch_r then draw_finger(touch_r) end end