New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step branch #1

Merged
merged 261 commits into from Jul 21, 2016
Commits
Jump to file or symbol
Failed to load files and symbols.
+15 −11
Diff settings

Always

Just for now

Viewing a subset of changes. View all

Rename the property vars to their full name. they will be minified au…

…tomatically
  • Loading branch information...
pvdz committed Feb 21, 2016
commit 128d96bea8aa0f7eabe8b567493d91f28ef1f0c5
View
@@ -176,6 +176,10 @@ <h1>
rr, // force speed if too slow (causes jitter). update speed with delta
size, // size of pixel to paint (depends on speed in most cases)
clearRect = 'clearRect',
fillStyle = 'fillStyle',
fillText = 'fillText',
// math constants
FLOOR,
MIN,
@@ -239,17 +243,17 @@ <h1>
sn = FLOOR(RANDOM() * elements.length);
s = elements[sn];
c.clearRect(OX, OY, M, M);
c[clearRect](OX, OY, M, M);
c.font = M + 'px serif';
c.fillStyle = '#00f';
c.fillText(sn, OX+M2, OY+M2, M);
c.fillStyle = '#f00';
c[fillStyle] = '#00f';
c[fillText](sn, OX+M2, OY+M2, M);
c[fillStyle] = '#f00';
// could init `i` to 1 instead of 0 here (we wouldnt notice the diff)
c.fillText(s[1] == ' ' ? s[0] : s[0] == '_' ? 'Uu' + s[1] : s, OX+M2, OY+M2, M);
c[fillText](s[1] == ' ' ? s[0] : s[0] == '_' ? 'Uu' + s[1] : s, OX+M2, OY+M2, M);
c.font = 0.1 * M + 'px serif';
c.fillStyle = '#0f0';
c.fillText('qfox.nl', OX + M2, OY + M *.9);
c[fillStyle] = '#0f0';
c[fillText]('qfox.nl', OX + M2, OY + M *.9);
qw = c.measureText('qfox.nl').width/2*1.2;
data = c.getImageData(OX, OY, M, M).data;
@@ -258,15 +262,15 @@ <h1>
i=0;
p=pixels[i++];
// pixel color
p.c = (!p.u) ? p.num ? '#ff0' : (p.q ? '#f0f' : '#000') : (p.u % 3 === 0) ? c.fillStyle = '#00f' : (p.u % 3 === 1) ? c.fillStyle = '#f00' : '#0f0'
p.c = (!p.u) ? p.num ? '#ff0' : (p.q ? '#f0f' : '#000') : (p.u % 3 === 0) ? c[fillStyle] = '#00f' : (p.u % 3 === 1) ? c[fillStyle] = '#f00' : '#0f0'
) {
// if data[x+0], the space is occupied by a letter. set p.u so the pixel joins the moving "atom".
p.u = data[t=(p.tx + p.ty * M) * 4] ? i : 0;
p.q = data[t + 1]; // qfox.nl
p.num = data[t + 2]; // number
}
c.clearRect(OX, OY, M, M);
c[clearRect](OX, OY, M, M);
}
F = 0.85; // friction. lower means faster pixels.
@@ -283,7 +287,7 @@ <h1>
// this loop updates the pixels
Z = 0;
(function R() {
Z++ % swapRate ? c.clearRect(OX - 25, OY - 25, M + 50, M + 50) : swap();
Z++ % swapRate ? c[clearRect](OX - 25, OY - 25, M + 50, M + 50) : swap();
time = Z % mt / mt;
tp = SIN(time);
@@ -317,7 +321,7 @@ <h1>
// size of pixel
size = p.q ? 4 : FLOOR(1+(vx+vy)*.2);
c.fillStyle = p.c;
c[fillStyle] = p.c;
c.fillRect(OX + FLOOR(p.x+=p.vx=vx*F) + .5, OY + FLOOR(p.y+=p.vy=vy*F) + .5, size, size);
}
ProTip! Use n and p to navigate between commits in a pull request.