Skip to content

Commit 739a7d9

Browse files
committed
simplify loop
1 parent a343cd1 commit 739a7d9

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

docs/ex/d3/orthographic-to-equirectangular.html

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,26 @@
3232
const path = d3.geoPath(projection, context);
3333

3434
const animation = (function* () {
35-
while (true) {
36-
for (let i = 0, n = 480; i < n; ++i) {
37-
const t = d3.easeCubic(2 * i > n ? 2 - 2 * i / n : 2 * i / n);
38-
projection.alpha(t).rotate(rotate(t)).scale(scale(t));
39-
context.clearRect(0, 0, width, height);
40-
context.beginPath();
41-
path(graticule);
42-
context.lineWidth = 1;
43-
context.strokeStyle = "#aaa";
44-
context.stroke();
45-
context.beginPath();
46-
path(sphere);
47-
context.lineWidth = 1.5;
48-
context.strokeStyle = "#000";
49-
context.stroke();
50-
context.beginPath();
51-
path(equator);
52-
context.lineWidth = 1.5;
53-
context.strokeStyle = "#f00";
54-
context.stroke();
55-
yield context.canvas;
56-
}
35+
for (let i = 0, n = 480; true; i = (i + 1) % n) {
36+
const t = d3.easeCubic(2 * i > n ? 2 - 2 * i / n : 2 * i / n);
37+
projection.alpha(t).rotate(rotate(t)).scale(scale(t));
38+
context.clearRect(0, 0, width, height);
39+
context.beginPath();
40+
path(graticule);
41+
context.lineWidth = 1;
42+
context.strokeStyle = "#aaa";
43+
context.stroke();
44+
context.beginPath();
45+
path(sphere);
46+
context.lineWidth = 1.5;
47+
context.strokeStyle = "#000";
48+
context.stroke();
49+
context.beginPath();
50+
path(equator);
51+
context.lineWidth = 1.5;
52+
context.strokeStyle = "#f00";
53+
context.stroke();
54+
yield context.canvas;
5755
}
5856
})();
5957

0 commit comments

Comments
 (0)