[ Launch: bart paths ] 6149065 by enjalot
-
-
Save enjalot/6149065 to your computer and use it in GitHub Desktop.
bart paths
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":"bart paths","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"bart.svg":{"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},"seglist.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":true,"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,"thumbnail":"http://i.imgur.com/r3ZQL7b.png"} |
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 svg = d3.select("svg"); | |
var trains = []; | |
var circleData = d3.range(6).map(function() { return {} }); | |
var lines = svg.select("#lines") | |
.selectAll("path") | |
.data(circleData) | |
.each(function(d) { | |
var n = Math.floor(1 + Math.random() * 6); | |
var node = this; | |
d3.range(n).forEach(function() { | |
trains.push({ | |
len: node.getTotalLength(), | |
node: node, | |
start: Math.random() | |
}) | |
}) | |
}) | |
var circles = svg.selectAll("circle") | |
.data(trains) | |
circles.enter() | |
.append("circle").classed("train", true) | |
.attr({ | |
cx: function(d) { return d.x }, | |
cy: function(d) { return d.y }, | |
r: 5, | |
fill: "#5C5A61", | |
stroke: "#eeeeee" | |
}) | |
tributary.run = function(g,t) { | |
circles.each(function(d,i) { | |
var o = (Math.sin(2 *Math.PI * (d.start + t/10)) + 1)/2; | |
var p = d.node.getPointAtLength(o*d.len); | |
d3.select(this).attr({ | |
cx: p.x, | |
cy: p.y | |
}) | |
}) | |
} | |
tributary.loop_type = "period"; |
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 richmond = svg.select("#richmond") | |
path = richmond; | |
var seglist = path.node().pathSegList; | |
//console.log(seglist); | |
var segPathData = d3.range(seglist.numberOfItems).map(function(d, i){ | |
var item = seglist.getItem(i); | |
return item; | |
}); | |
//console.log("list:", segPathData); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment