Skip to content

Instantly share code, notes, and snippets.

@paulirish
Created August 17, 2015 05:14
Show Gist options
  • Save paulirish/21326986569181e47f21 to your computer and use it in GitHub Desktop.
Save paulirish/21326986569181e47f21 to your computer and use it in GitHub Desktop.
Winning 1kb intro released at Assembly 2015 - https://news.ycombinator.com/item?id=10068655
function u() {
requestAnimationFrame(u);
g = p ?
audio.currentTime * 60 : (
audio = "RIFFdataWAVEfmt " + atob("EAAAAAEAAQAAeAAAAHgAAAEACAA") + "data",
b.style.background = "radial-gradient(circle,#345,#000)",
b.style.position = "fixed",
b.style.height = b.style.width = "100%",
b.height = 720,
h = b.style.left = b.style.top = A = f = C = 0,
6177
);
for (; g > f; h *= f % 1 ? 1 : 0.995) {
s = Math.pow(Math.min(f / 5457, 1), 87) + Math.pow(1 - Math.min(f / 5457, 1), 8);
if (f == [b.width = 1280, 1599, 2175, 2469, 2777, 3183, 3369, 3995, 4199, 4470, 4777, 5120][C]) {
C++;
h = 640;
}
f += p ?
(ctx.translate(640, 360 + h / 45 * Math.random()),
ctx.rotate(A / 5457 - h / 5457),
ctx.scale(1 + s * 8, 1 + s * 8),
1)
:
(audio += T((1 + s * 8) * Math.random() + (1 - s) * (h / 45 * (f * (2 + C / 3 % 1) & 1) + (C > 3) * 8 * (f * (2 + (f / 8 & 3)) % 1)) | 1), 1 / 512);
i = p.length;
for (; i; ) {
y = p[i -= 7];
x = p[i ^= 1];
r = p[i + 4];
l = p[i + 6];
s = 2 * Math.random() + 1;
t = s * 4;
a = 122;
if (640 > r) {
if (!(640 > Math.abs(p[i ^= 1] += p[i + 2]))) {
p[i + 2] *= -1;
}
if (!(640 > Math.abs(p[i ^= 1] += p[i + 2]))) {
p[i + 2] *= -1;
}
t = Math.random() > p[i + 7] || p[i + 7] == "22312131212313"[C] & h == 640;
w = x - A;
if (!p[i + 2]) {
if (r * r / 3 > w * w) {
t = s * (r - Math.abs(w)) / 45 + 2;
a = 2 * Math.random() + 5;
p.push(A, 0, s * Math.sin(a += 599), s * Math.sin(a - 11), s * t, C + s, 640, 0.995);
s = 2 * Math.random() + 1;
a = 2 * Math.random() + 5;
p.push(A, 0, s * Math.sin(a += 599), s * Math.sin(a - 11), s * t, C + s, 640, 0.995);
s = 2 * Math.random() + 1;
a = 2 * Math.random() + 2;
p.push(A, 0, s * Math.sin(a += 599), s * Math.sin(a - 11), s * t, C + s, 640, 0.995);
}
}
a = p[i + 2] * y / 45;
l = p[i + 6] = t ? 640 : 0.9 * l;
t = r;
} else {
A = p[i]++;
}
if (!(g > f)) {
s = r;
ctx.beginPath();
ctx.lineTo(x + s * Math.sin(a += 599), y - s * Math.sin(a - 11));
s = t;
ctx.lineTo(x + s * Math.sin(a += 599), y - s * Math.sin(a - 11));
ctx.lineTo(x + s * Math.sin(a += 599), y - s * Math.sin(a - 11));
ctx.shadowBlur = r;
s = l;
x = s * 2;
a = p[i + 5];
ctx.shadowColor = ctx.fillStyle = "rgb(" + [x + s * Math.sin(a += 599) | 1, x + s * Math.sin(a += 599) | 1, x + s * Math.sin(a += 599) | 1] + ")";
ctx.fill();
}
}
}
if (p) {
ctx.fillText("BLCK4777", 90, 99);
} else {
(audio = new Audio("data:Audio/WAV;base64," + btoa(audio))).play(p = [f = C = 0, 0, 0, 0, 180, 2, 0, 1, -360, 0, 0, 0, 99, 1, 0, 2, 360, 0, 0, 0, 99, 1, 0, 3, -2880, 0, 0, 0, 1280, 0, 1280, 0]);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment