Skip to content

Instantly share code, notes, and snippets.

@mbostock
Last active February 9, 2016 00:45
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 mbostock/1322948 to your computer and use it in GitHub Desktop.
Save mbostock/1322948 to your computer and use it in GitHub Desktop.
Poor Anti-Aliasing in SVG, #2

400 coincident opaque svg:line elements, each .5-pixel wide. The coincident lines on the left should appear identical to the single line on the right.

<!DOCTYPE html>
<meta charset="utf-8">
<style>
line {
stroke: #000;
stroke-width: .5px;
}
</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script>
var svg = d3.select("body").append("svg")
.attr("width", 960)
.attr("height", 500);
svg.selectAll("line")
.data(d3.range(400))
.enter().append("line")
.attr("x2", 480)
.attr("y2", 500);
svg.append("line")
.attr("transform", "translate(480)")
.attr("x2", 480)
.attr("y2", 500);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment