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.
+6 −10
Diff settings

Always

Just for now

Viewing a subset of changes. View all

Caching a division is only shorter if you use it more than twice. Mov…

…ed the vx/vy update such that we can immediately store it to pixel.
  • Loading branch information...
pvdz committed Feb 18, 2016
commit 8e557942315d125670e744e011535174117b8dee
View
@@ -154,13 +154,13 @@ <h1>
var M2 = FLOOR(M/2); // mid of view
var OX = FLOOR(W/2 - M2);
var OY = FLOOR(H/2 - M2);
var N = M / K; // pixel step per particle
var pixels = [];
for (var i = 0; i < K; ++i) {
for (var j = 0; j < K; ++j) {
var v;
pixels.push({
// init in centrum
// init in centre
x: M2,
y: M2,
@@ -169,8 +169,8 @@ <h1>
vy: v,
// default position unless special
tx: FLOOR(i * N),
ty: FLOOR(j * N),
tx: FLOOR(i * M/K),
ty: FLOOR(j * M/K),
});
}
}
@@ -290,12 +290,11 @@ <h1>
// update speed
var acc = 2-d/500;
vx = (vx - COS(dtan) * acc) * F;
vy = (vy - SIN(dtan) * acc) * F;
// force speed (causes jitter)
if (ABS(vx) < .1) vx *= RANDOM() * 3;
if (ABS(vy) < .1) vy *= RANDOM() * 3;
p.vx = vx = (vx - COS(dtan) * acc) * F;
p.vy = vy = (vy - SIN(dtan) * acc) * F;
// size of pixel
var size = FLOOR(1+(vx+vy)*(p.q ?.8:.2));
@@ -307,9 +306,6 @@ <h1>
else c.fillStyle = 'green';
c.fillRect(OX + FLOOR(p.x=x + vx) + .5, OY + FLOOR(p.y=y + vy) + .5, size, size);
p.vx = vx;
p.vy = vy;
}
requestAnimationFrame(R);
ProTip! Use n and p to navigate between commits in a pull request.