info = { type = "image", title = "White bunny", category = "animals", author = "BRRRO", version = "1.0", license = "MIT", desc = "A fluffy bunny blinks and twitches its ears", api = 33, } local ltr = ({ sk = { ["Background"] = "Pozadie" }, cs = { ["Background"] = "Pozadí" }, })[lang] or {} local function LT(s) return ltr[s] or s end settings = { { key = "bg", label = LT("Background"), type = "color", default = "#D8CCF4" }, } local rect, px, blend, blit = gfx.rect, gfx.px, gfx.blend, gfx.blit_indexed local floor, sin, cos, sqrt, abs = math.floor, math.sin, math.cos, math.sqrt, math.abs local hash32, umod = math.hash32, math.umod local W, H, FPS = gfx.W, gfx.H, gfx.FPS local TAU = 6.28318 local OUT, FUR, SHD, PINK, PINKL, LINE = 1, 2, 3, 4, 5, 6 local C_FUR, C_SHD, C_LINE = { 252, 252, 255 }, { 214, 222, 246 }, { 178, 186, 224 } local C_PINK, C_PINKL, C_NOSE = { 250, 150, 182 }, { 255, 206, 222 }, { 238, 104, 146 } local C_EYE = { 50, 38, 76 } local RUNS = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 29, 31, 34, 72, 118, 124, 153 }, { 1, 1, 2, 3, 4, 5, 7, 12 }, { 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 24, 25, 27, 29, 30, 31, 32, 34, 36 }, { 3, 1, 2, 3, 4, 5, 6, 7, 12, 14, 15, 17, 20 }, { 4, 1, 2, 3, 4, 5, 6, 7 }, { 5, 1, 3, 4 }, { 6, 1, 2, 3, 6, 7, 14 } } local UNZ = { ["\n"] = "" } do local c = 33 for _, r in ipairs(RUNS) do local v = string.char(r[1]) for k = 2, #r do if c == 93 then c = 94 end UNZ[string.char(c)] = v:rep(r[k]) c = c + 1 end end end local function unz(s) return (s:gsub(".", UNZ)) end local BX0, BY0, BW, BH = 2, 30, 50, 30 local HX0, HY0, HW, HH = 24, 6, 36, 38 local byte = string.byte local B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?f?$?GpF?1?g?#?GpG?0?cpd?"?GqG?0?cqd?!?GqG?0?dqd@GqG?0?dqd?GqG?1?dqd?GqG?2?dqc?GqG ?2?dqdyFpG?4?dpdyFpFy@4?dozFyGyH@3?zH{K?1?R?/?T?.?T?-?V?,?V?,?V?+?X?+?W?+yX?*yX?+yW?+yW?,yhP?.ym?0zk ?3}g@8{@<]], [[ >?:?c@9?f?8!?g?8?cpd?8?cqd?7"?dqd?7?F{zd?6!?LzF?6?GsI?6?GuG?5?HuGC1@IsFyI@1?FzJyL?1?G{zN?/?T?.?T?-?V ?,?V?,?V?+?X?+?W?+yX?*yX?+yW?+yW?,yhP?.ym?0zk?3}g@8{@<]] } local BODY, HEAD = {}, {} local function body(k) local s = BODY[k] if not s then s = unz(BODYZ[k]); BODY[k] = s end return s end local function head(e) local s = HEAD[e] if not s then s = unz(HEADZ[e]); HEAD[e] = s end return s end local SPOTS, NSPOT = "\3\3\6\3\9\3\12\3\15\3\18\3\21\3\24\3\27\3\30\3\33\3\36\3\39\3\42\3\45\3\48\3\51\3\54\3\57\3\60\3\3\6\6\6\9\6\12\6\15\6\18\6\21\6\24\6\27\6\30\6\33\6\36\6\39\6\42\6\45\6\48\6\51\6\54\6\57\6\60\6\3\9\6\9\9\9\12\9\15\9\18\9\21\9\24\9\27\9\51\9\54\9\57\9\60\9\3\12\6\12\9\12\12\12\15\12\18\12\21\12\24\12\27\12\51\12\54\12\57\12\60\12\3\15\6\15\9\15\12\15\15\15\18\15\21\15\24\15\27\15\51\15\54\15\57\15\60\15\3\18\6\18\9\18\12\18\15\18\18\18\21\18\24\18\51\18\54\18\57\18\60\18\3\21\6\21\9\21\12\21\15\21\18\21\21\21\24\21\54\21\57\21\60\21\3\24\6\24\9\24\12\24\15\24\18\24\21\24\24\24\27\24\57\24\60\24\3\27\6\27\9\27\12\27\15\27\18\27\21\27\24\27\27\27\57\27\60\27\3\30\6\30\9\30\12\30\15\30\60\30\3\33\6\33\9\33\12\33\60\33\3\36\6\36\9\36\60\36\3\39\57\39\60\39\54\42\57\42\60\42\51\45\54\45\57\45\60\45\51\48\54\48\57\48\60\48\51\51\54\51\57\51\60\51", 157 local function rgb2hsv(r, g, b) r, g, b = r / 255, g / 255, b / 255 local mx, mn = math.max(r, g, b), math.min(r, g, 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 * 60, mx > 0 and d / mx or 0, mx end local function hsv2rgb(h, s, v) if s > 1 then s = 1 end if v > 1 then v = 1 end local c = v * s local hp = (h % 360) / 60 local x = c * (1 - abs(hp % 2 - 1)) local r, g, b if hp < 1 then r, g, b = c, x, 0 elseif hp < 2 then r, g, b = x, c, 0 elseif hp < 3 then r, g, b = 0, c, x elseif hp < 4 then r, g, b = 0, x, c elseif hp < 5 then r, g, b = x, 0, c else r, g, b = c, 0, x end local m = v - c return { floor((r + m) * 255 + 0.5), floor((g + m) * 255 + 0.5), floor((b + m) * 255 + 0.5) } end local BGC, C_OUT, C_GND = { 216, 204, 244 }, { 120, 96, 166 }, { 190, 176, 228 } local C_SPK = { 255, 206, 96 } local PAL = {} local BG = nil local function apply(c) BGC = { c.r, c.g, c.b } local h, s, v = rgb2hsv(c.r, c.g, c.b) C_OUT = hsv2rgb(h, s * 1.5 + 0.18, v * 0.62) C_GND = hsv2rgb(h, s * 1.15 + 0.06, v * 0.86) PAL = { 0, 0, 0 } for _, col in ipairs({ C_OUT, C_FUR, C_SHD, C_PINK, C_PINKL, C_LINE }) do PAL[#PAL + 1], PAL[#PAL + 2], PAL[#PAL + 3] = col[1], col[2], col[3] end BG = nil end apply({ r = 216, g = 204, b = 244 }) function on_settings() apply(cfg.bg or { r = 216, g = 204, b = 244 }) end local function minifl(x, y) px(x, y, 255, 214, 90) px(x - 1, y, 255, 255, 255); px(x + 1, y, 255, 255, 255) px(x, y - 1, 255, 255, 255); px(x, y + 1, 255, 255, 255) end local function build_bg() rect(0, 0, W, H, BGC[1], BGC[2], BGC[3]) for j = -2, 2 do local half = floor(26 * sqrt(1 - (j / 2.9) ^ 2) + 0.5) rect(31 - half, 59 + j, 2 * half + 1, 1, C_GND[1], C_GND[2], C_GND[3]) end minifl(4, 59); minifl(60, 58) BG = gfx.snapshot(0, 0, W, H) end local SPK = { { 2.57, 0 }, { 3.13, 1.03 }, { 3.7, 1.93 }, { 4.27, 0.4 } } local function sparkles(t) for s = 1, #SPK do local per, off = SPK[s][1], SPK[s][2] local age = (t + off) % per if age < 0.7 then local cyc = floor((t + off) / per) local i = umod(hash32(s * 0x9E3779B1 + cyc * 0x85EBCA6B), NSPOT) local x, y = byte(SPOTS, 2 * i + 1, 2 * i + 2) local st = floor(age * 10) local arm = (st == 2 or st == 3) and 2 or ((st == 1 or st == 4) and 1 or 0) if st == 6 then px(x, y, C_SPK[1], C_SPK[2], C_SPK[3]) else px(x, y, 255, 255, 255) for a = 1, arm do px(x - a, y, C_SPK[1], C_SPK[2], C_SPK[3]); px(x + a, y, C_SPK[1], C_SPK[2], C_SPK[3]) px(x, y - a, C_SPK[1], C_SPK[2], C_SPK[3]); px(x, y + a, C_SPK[1], C_SPK[2], C_SPK[3]) end end end end end function render() if not BG then build_bg() end gfx.blit_rgb(BG, 0, 0, W, H) local t = frame / FPS local k = floor(2.0 + 1.6 * sin(t * TAU / 3.2)) if k < 0 then k = 0 elseif k > 3 then k = 3 end blit(body(k), PAL, BX0, BY0, BW, BH, BW, BH, true) local e, et = 0, t - 4.2 local n, tau = floor(et / 6), et % 6 if n % 2 == 0 then if tau < 2 then e = 2 end elseif tau < 0.1 or (tau >= 0.2 and tau < 0.3) then e = 1 end blit(head(e), PAL, HX0, HY0, HW, HH, HW, HH, true) if (t - 4.67) % 3.7 < 0.133 then rect(45, 29, 3, 1, C_OUT[1], C_OUT[2], C_OUT[3]) else rect(46, 27, 2, 3, C_EYE[1], C_EYE[2], C_EYE[3]) px(46, 27, 255, 255, 255) end local nt = t % 2.3 local ny = (nt < 0.4 and floor(nt * 15) % 2 == 0) and 30 or 31 rect(52, ny, 2, 1, C_NOSE[1], C_NOSE[2], C_NOSE[3]) blend(48, 32, C_PINK[1], C_PINK[2], C_PINK[3], 0.65) blend(49, 32, C_PINK[1], C_PINK[2], C_PINK[3], 0.65) sparkles(t) end