Skip to content

Instantly share code, notes, and snippets.

@vlandham
Created October 12, 2013 03:50
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 vlandham/6945600 to your computer and use it in GitHub Desktop.
Save vlandham/6945600 to your computer and use it in GitHub Desktop.
clipping path notes
Here is the final product:
http://www.mappinghealth.com/flu#sim
The code is complex because I am doing other things such as "zooming
out" while the circle is growing. But here is the clip definition. one
thing that I found counter-intuitive is that the clipping shape is
actually a window that allows the background to show through, rather
than a shape that obstructs others.
outer_vis.append("svg:clipPath")
.attr("id", "clip-window")
.append("svg:circle")
.attr("id", "clip-circle")
.attr("r", clip_circle_radius)
;
vis = outer_vis.append("svg:g")
.attr("clip-path", "url(#clip-window)")
.attr("transform", "translate(" + r + "," + r + ")")
;
and then to grow the circle:
outer_vis.select("#clip-
circle").transition().duration(frame*2).attr("r", clip_circle_radius);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment