Skip to content

Instantly share code, notes, and snippets.

@vicapow
Last active August 29, 2015 14:05
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 vicapow/a794b4fb484db91a1a1c to your computer and use it in GitHub Desktop.
Save vicapow/a794b4fb484db91a1a1c to your computer and use it in GitHub Desktop.
laser!
<!DOCTYPE html>
<html>
<script src="http://d3js.org/d3.v3.js" charset="utf-8"></script>
<body>
<script>
var w = 800, h = 800, n = 40
var svg = d3.select('body').append('svg')
.attr({width: w, height: h})
var data = d3.range(n)
.map(function(d) { return (d + 1) / n / 2 })
.sort(function(a, b){ return b - a })
var g = svg.selectAll('g').data(data)
.enter().append('g')
.attr('transform', function(d) {
return 'translate(' + [ w / 2, h / 2 ] + ') rotate(' + d * 900 + ')'
})
g.append('rect')
.style('fill', 'none')
.style('stroke', 1)
.attr('x', function(d) { return - w * d * 0.5 })
.attr('y', function(d) { return -h * d * 0.5 })
.attr('width', function(d) { return w * d })
.attr('height', function(d) { return h * d })
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment