[ Launch: Tributary inlet ] 4649351 by tmcw
-
-
Save tmcw/4649351 to your computer and use it in GitHub Desktop.
Tributary inlet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"Tributary inlet","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pts = []; | |
d3.range(0, 30).forEach(function(x) { | |
return d3.range(0, 30).forEach(function(y) { | |
pts.push([x, y]); | |
}); | |
}); | |
var x = d3.scale.linear().range([10, 200]).domain([0, 10]); | |
var y = d3.scale.linear().range([10, 200]).domain([0, 10]); | |
var svg = d3.select("svg") | |
.append("svg:g") | |
var rect = svg.selectAll('rect') | |
.data(pts) | |
.enter() | |
.append('rect') | |
.attr({ width: 15, height: 15 }) | |
.attr('transform', function(d) { | |
return 'translate(' + [x(d[0]), y(d[1])] + ')'; | |
}); | |
d3.timer(function() { | |
var t = (+new Date() / 1000); | |
rect.attr('transform', function(d) { | |
return 'translate(' + [x(d[0]), y(d[1])] + ') rotate(' + (Math.sin(d[0] + d[1] + t) * 30) + ' 5 5)'; | |
}) | |
.attr('fill', function(d) { | |
return 'hsl(' + (Math.sin(d[0] + d[1] + t) * 30) + ', 90%, 50%)'; | |
}); | |
}, 100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment