Skip to content

Instantly share code, notes, and snippets.

@jasondavies
Created July 9, 2012 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasondavies/3076420 to your computer and use it in GitHub Desktop.
Save jasondavies/3076420 to your computer and use it in GitHub Desktop.
Geographic Clipping: Spiral
<!DOCTYPE html>
<meta charset="utf-8">
<title>Geographic Clipping of Spiral</title>
<body>
<script src="http://d3js.org/d3.v2.min.js"></script>
<script src="https://raw.github.com/d3/d3-plugins/clip/geo/clip/clip.js"></script>
<script>
var xy = d3.geo.azimuthal().scale(200).mode("orthographic").origin([0, 90]),
dy = 5,
clip = d3.geo.clip().origin([0, 90]),
path = d3.geo.path().projection(xy),
svg = d3.select("body").append("svg"),
n = 1000;
var origin = [0, 0],
velocity = [.01, .01],
t0 = Date.now();
var spiral = d3.range(0, 1 + 1 / n, 1 / n).map(function(t) {
return [(360 * 10 * t) % 360 - 180, -90 + dy + (90 - dy) * 2 * t];
}).concat(d3.range(1, 0, -1 / n).map(function(t) {
return [(360 * 10 * t) % 360 - 180, -90 + (90 - dy) * 2 * t];
}));
spiral.push(spiral[0]);
var a = svg.append("path")
.datum({type: "Polygon", coordinates: [spiral]});
d3.timer(function() {
var t = Date.now() - t0,
o = [origin[0] + t * velocity[0], origin[1] + t * velocity[1]];
xy.origin(o);
clip.origin(o);
a.attr("d", function(d) { return path(clip(d)); });
});
</script>
@syntagmatic
Copy link

clip branch is missing for this one too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment