Hamster Wheel
của MusicBar, thanh tiến trình
Bé hamster mũm mĩm chạy trong bánh xe lăn tới chỗ đang phát, nhạc càng to chân càng chạy lẹ, hạt hướng dương rải phía trước bị cắn thành vỏ, tới nhịp là nhảy tưng lên trong bánh xe.
Cách cài, mã SHA-256 và mã nguồn
Bấm Áp dụng: MusicBar tự tải về, kiểm tra mã SHA-256 rồi mặc lên taskbar; có rồi thì mặc luôn. Cần MusicBar 1.8 trở lên.
SHA-256 163923c608ea34ec5623288da376a46da013a223019ff7bd2344c37d27496669
//! name: Hamster Wheel
//! author: MusicBar
//! kind: progress
//! description: A chubby hamster sprints inside a rolling wheel to the playhead, legs churning faster when the song gets loud, cracking the sunflower seeds ahead into husks and hopping up inside the wheel on every beat.
float hash1(float n) { return frac(sin(n * 127.1 + 311.7) * 43758.5453); }
// Turns a point around the origin by a (radians, counterclockwise).
float2 rot(float2 p, float a) { float c = cos(a), s = sin(a); return float2(c * p.x - s * p.y, s * p.x + c * p.y); }
// Signed distance to an ellipse with radii r (close enough near the edge).
float ellipse(float2 p, float2 r) { float k0 = length(p / r); return k0 * (k0 - 1.0) / max(length(p / (r * r)), 0.0001); }
// Smooth minimum: melts the head into the body.
float smin(float a, float b, float k) { float h = saturate(0.5 + 0.5 * (b - a) / k); return lerp(b, a, h) - k * h * (1.0 - h); }
// A sunflower seed lying along +x, len long: round at the back, pointed at the tip.
float seed(float2 p, float len) { float t = saturate(p.x / len + 0.5); return ellipse(float2(p.x, p.y / lerp(1.0, 0.4, t * t)), float2(0.5, 0.21) * len); }
// Cream stripes along a dark seed, with a pale rim so it shows on a dark taskbar.
float3 seedColor(float2 p, float d, float len)
{
float t = saturate(p.x / len + 0.5);
float v = abs(p.y) / (0.21 * len * lerp(1.0, 0.4, t * t));
float st = smoothstep(0.17, 0.07, v) + smoothstep(0.15, 0.06, abs(v - 0.6));
float3 c = lerp(float3(0.13, 0.12, 0.13), float3(0.9, 0.88, 0.8), saturate(st) * 0.9);
c *= 0.8 + 0.35 * smoothstep(0.5, -0.5, p.y / (0.2 * len));
return lerp(c, float3(0.78, 0.76, 0.7), smoothstep(-0.035 * len, 0.0, d));
}
// Lays a color over what is there (premultiplied light, and how much of the pixel it covers).
void layer(inout float3 acc, inout float cover, float3 rgb, float a)
{
a = saturate(a);
acc = rgb * a + acc * (1.0 - a);
cover = a + cover * (1.0 - a);
}
float4 main(float2 uv : TEXCOORD) : COLOR
{
float u = size.y;
float2 px = float2(uv.x * size.x, (1.0 - uv.y) * u); // pixels, up the screen so the wheel stands on a top taskbar too
float2 p = px / u; // the same in bar heights
float hx = progress * size.x / u;
float aa = 1.0 / u; // one pixel in bar heights
float back = hx - p.x; // bar heights behind the playhead
float sweep = (8.0 + 14.0 * level) / 60.0; // half the angle the wheel turns in a frame: more blur when loud
float R = 0.45, wc = 0.5; // wheel radius and axle height
float2 w = p - float2(hx, wc);
float wr = length(w), wa = atan2(w.y, w.x);
float spin = time * 11.0 + hx / R;
float3 acc = float3(0, 0, 0);
float cover = 0;
// Bedding over the played part: a fluffy heap of wood shavings with curls on top, thinning far back.
float top = 0.07 + 0.045 * abs(sin(p.x * 4.1)) + 0.02 * sin(p.x * 11.3 + 1.7);
float bed = smoothstep(aa, -aa, p.y - top) * smoothstep(0.25, 0.6, back);
float grain = 0.85 + 0.15 * sin(p.x * 23.0 + sin(p.y * 19.0 + p.x * 2.0) * 3.0);
float fade = lerp(0.9, 0.5, saturate(back / 30.0));
layer(acc, cover, lerp(colorB.rgb * 0.55, colorB.rgb * 1.05, smoothstep(0.0, top, p.y)) * grain, bed * fade);
float cc = floor(p.x / 0.17);
float ch = hash1(cc * 2.3 + 5.0);
float2 cq = p - float2((cc + 0.5) * 0.17, top - 0.015 * ch);
float curl = abs(length(cq) - 0.03 - 0.02 * ch) - 0.009;
layer(acc, cover, lerp(colorB.rgb, float3(1, 0.97, 0.9), 0.45), smoothstep(aa, -aa, curl) * step(-0.005, cq.y) * step(0.3, ch) * smoothstep(0.5, 0.9, back) * fade);
// Cracked husks left in the bedding: two shell halves splayed open at the tip.
float hc = floor(p.x / 0.6);
float hh = hash1(hc * 3.7 + 1.0);
float2 hq = rot(p - float2((hc + 0.25 + 0.5 * hh) * 0.6, 0.095 + 0.03 * hh), (hh - 0.5) * 0.9);
float2 qa = rot(hq - float2(0.1, 0.0), 0.3) + float2(0.1, -0.012), qb = rot(hq - float2(0.1, 0.0), -0.3) + float2(0.1, 0.012);
float dh = min(max(seed(qa, 0.2), -qa.y), max(seed(qb, 0.2), qb.y));
float husk = smoothstep(aa, -aa, dh) * step(0.3, hh) * smoothstep(0.7, 1.2, back);
layer(acc, cover, lerp(seedColor(hq, dh, 0.2), float3(0.62, 0.6, 0.55), 0.4), husk * lerp(0.85, 0.5, saturate(back / 30.0)));
// Sunflower seeds scattered ahead, rocking with the music; they jump a little on the beat near the wheel.
float sc = floor(p.x / 0.85);
float sh = hash1(sc * 5.1 + 2.0);
float sjig = spectrum(frac(sh * 7.0) * 0.6);
float sx = (sc + 0.25 + 0.5 * sh) * 0.85;
float kick = beat * exp(-max(sx - hx, 0.0) / 1.5);
float2 sq = rot(p - float2(sx, 0.1 + 0.12 * kick), (sh - 0.5) * 1.2 + 0.3 * sin(time * 5.0 + sh * 20.0) * sjig + 2.0 * kick);
sq.x *= sign(frac(sh * 13.0) - 0.5);
float ds = seed(sq, 0.27);
float ahead = smoothstep(hx + 0.45, hx + 0.6, sx) * step(0.2, frac(sh * 31.0));
layer(acc, cover, float3(0, 0, 0), smoothstep(0.04, -0.01, ellipse(p - float2(sx, 0.035), float2(0.12, 0.02))) * 0.25 * ahead);
layer(acc, cover, float3(0.85, 0.83, 0.75), exp(-max(ds, 0.0) / 0.03) * 0.12 * ahead);
layer(acc, cover, seedColor(sq, ds, 0.27), smoothstep(aa, -aa, ds) * ahead * 0.9);
// A faint dotted path for the rest of the song.
float dots = smoothstep(1.4 * aa, 0.4 * aa, length(float2((frac(p.x / 0.3) - 0.5) * 0.3, p.y - 0.04)) - 0.012);
layer(acc, cover, colorA.rgb, dots * step(hx + 0.6, p.x) * 0.35);
// Shavings flicked back by the wheel, falling as they fly.
for (int i = 0; i < 6; i++)
{
float r = hash1(i * 7.7 + 3.0);
float t = frac(time * (1.1 + 0.6 * r) + i / 6.0);
float2 f = float2(hx - 0.25 - t * (0.9 + 0.8 * r), 0.06 + t * (0.5 + 0.4 * r) - t * t * 0.9);
float2 fq = rot(p - f, t * 9.0 + r * 6.0);
float fd = ellipse(fq, float2(0.032, 0.013));
layer(acc, cover, lerp(colorB.rgb, float3(1, 1, 1), 0.3), smoothstep(aa, -aa, fd) * (1.0 - t) * (0.35 + 0.65 * level));
}
// The wheel's soft shadow and glow, then the see-through back with blurred spokes.
layer(acc, cover, float3(0, 0, 0), smoothstep(0.03, -0.02, ellipse(p - float2(hx, 0.02), float2(0.4, 0.035))) * 0.35);
layer(acc, cover, colorA.rgb, exp(-abs(wr - R) / 0.07) * (0.22 + 0.2 * level) * step(R, wr));
layer(acc, cover, colorA.rgb * 0.5, smoothstep(R, R - 0.02, wr) * 0.14);
float arc = abs(frac((wa + spin) / 1.0472 + 0.5) - 0.5) * 1.0472;
float sw = 0.022 / max(wr, 0.05);
float spoke = smoothstep(sw + sweep + aa / max(wr, 0.05), sw - aa / max(wr, 0.05), arc) * sw / (sw + sweep);
layer(acc, cover, lerp(colorA.rgb, float3(1, 1, 1), 0.3), saturate(spoke * 1.6) * step(wr, R - 0.03) * step(0.05, wr));
// The hamster runs on the inside of the rim, a little up the front; on the beat it hops toward the axle.
float hop = 0.45 * sqrt(beat) * (1.0 - sqrt(beat));
float2 slow = float2(cos(time * 15.0), sin(time * 15.0)), fast = float2(cos(time * 34.0), sin(time * 34.0));
float2 cyc = lerp(slow, fast, saturate(level * 1.3)); // the stride cycle: a trot, a blur of feet when loud
float2 q = rot(w - rot(float2(0.0, -(R - 0.04)), 0.32), -0.32) - float2(0.0, hop + 0.012 * abs(cyc.y));
q.y /= 1.0 + 0.12 * hop;
float2 fA = float2(0.1 + 0.06 * cyc.x, 0.025 + 0.04 * max(cyc.y, 0.0));
float2 fB = float2(-0.11 - 0.06 * cyc.x, 0.025 + 0.04 * max(-cyc.y, 0.0));
float2 fC = float2(0.08 - 0.06 * cyc.x, 0.025 + 0.04 * max(-cyc.y, 0.0));
float2 fD = float2(-0.13 + 0.06 * cyc.x, 0.025 + 0.04 * max(cyc.y, 0.0));
float far = min(ellipse(q - fC, float2(0.04, 0.026)), ellipse(q - fD, float2(0.045, 0.026)));
float nearF = min(ellipse(q - fA, float2(0.04, 0.026)), ellipse(q - fB, float2(0.045, 0.026)));
float bodyD = smin(ellipse(q - float2(-0.04, 0.15), float2(0.19, 0.135)), ellipse(q - float2(0.12, 0.17), float2(0.105, 0.098)), 0.05);
float earD = length(q - float2(0.065, 0.265)) - 0.045;
float tailD = length(q - float2(-0.225, 0.13)) - 0.028;
float ham = min(min(bodyD, earD), min(nearF, tailD));
layer(acc, cover, float3(1.0, 0.62, 0.66) * 0.7, smoothstep(aa, -aa, far));
layer(acc, cover, float3(0.28, 0.13, 0.05), smoothstep(aa, -aa, ham - 1.3 * aa));
float2 n = (q - float2(-0.01, 0.12)) / float2(0.26, 0.17);
float3 fur = lerp(float3(0.98, 0.64, 0.28), float3(0.82, 0.45, 0.18), smoothstep(0.1, 0.9, n.y - 0.3 * n.x));
fur = lerp(fur, float3(1.0, 0.95, 0.86), smoothstep(0.1, 0.06, q.y + 0.02 * sin(q.x * 20.0)) + smoothstep(0.03, 0.0, length(q - float2(0.16, 0.13)) - 0.04));
fur *= 0.78 + 0.3 * saturate(1.0 - length(n - float2(0.2, 0.5)));
layer(acc, cover, float3(1.0, 0.68, 0.7), smoothstep(aa, -aa, min(nearF, tailD + 0.012)));
layer(acc, cover, fur, smoothstep(aa, -aa, min(bodyD, earD)));
layer(acc, cover, float3(1.0, 0.6, 0.68), smoothstep(aa, -aa, length(q - float2(0.068, 0.262)) - 0.024));
layer(acc, cover, lerp(colorC.rgb, float3(1, 0.6, 0.7), 0.4), smoothstep(0.04, 0.0, length((q - float2(0.15, 0.125)) / float2(1.0, 0.75))) * 0.55);
float blink = step(0.96, frac(time * 0.29));
float eyeD = length((q - float2(0.152, 0.2)) / float2(1.0, lerp(1.0, 0.15, blink))) - 0.032;
layer(acc, cover, float3(0.05, 0.03, 0.04), smoothstep(aa, -aa, eyeD));
layer(acc, cover, float3(1, 1, 1), smoothstep(aa, -aa, length(q - float2(0.162, 0.213)) - 0.011) * (1.0 - blink));
layer(acc, cover, float3(0.95, 0.4, 0.5), smoothstep(aa, -aa, length(q - float2(0.222, 0.165)) - 0.016));
// The rim in front: a glossy plastic ring with rungs on the inside, blurred into streaks by the spin.
float rimD = abs(wr - R) - 0.03;
float rung = abs(frac((wa + spin) / 0.2618 + 0.5) - 0.5) * 0.2618;
float rw = 0.012 / R;
float rungs = smoothstep(rw + sweep + 0.02, rw, rung) * rw / (rw + sweep) * 2.5;
float shine = smoothstep(0.012, 0.0, abs(wr - R - 0.008)) * saturate(0.3 + w.y / R);
layer(acc, cover, lerp(colorA.rgb, float3(1, 1, 1), 0.2), saturate(rungs) * 0.8 * step(R - 0.08, wr) * step(wr, R - 0.02));
layer(acc, cover, colorA.rgb * 0.85, smoothstep(aa, -aa, abs(wr - R + 0.08) - 0.6 * aa) * 0.7);
layer(acc, cover, colorA.rgb * (0.65 + 0.45 * saturate(w.y / R + 0.5)) + 0.5 * shine, smoothstep(aa, -aa, rimD));
layer(acc, cover, colorA.rgb * 0.3, smoothstep(aa, -aa, abs(rimD + 0.2 * aa) - 0.7 * aa) * 0.6);
float hub = length(w) - 0.055; // the axle hub
layer(acc, cover, colorA.rgb * 0.3, smoothstep(aa, -aa, hub - aa));
layer(acc, cover, lerp(colorA.rgb, float3(1, 1, 1), 0.35 + 0.4 * smoothstep(0.04, 0.0, length(w - float2(-0.015, 0.02)))), smoothstep(aa, -aa, hub));
return paint(acc / max(cover, 0.001), cover);
}