[ Launch: Moving along path practice ] 6133585 by tarvaina
[ Launch: Tributary inlet ] 6133395 by tarvaina
-
-
Save tarvaina/6133585 to your computer and use it in GitHub Desktop.
temp
This file contains hidden or 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":"temp","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}},"fullscreen":false,"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,"thumbnail":"http://i.imgur.com/agfRjl2.png"} |
This file contains hidden or 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 data = [ | |
| { x: 0, y: 50 }, | |
| { x: 80, y: 0 }, | |
| { x: 120, y: 70 }, | |
| { x: 170, y: 80 }, | |
| { x: 250, y: 50 } | |
| ] | |
| var line = d3.svg.line() | |
| .x(function(v) { return v.x; }) | |
| .y(function(v) { return v.y; }); | |
| var svg = d3.select("svg"); | |
| var group = svg.append("g") | |
| .attr("transform", "translate(" + [100, 100] + ")"); | |
| var path = group.selectAll("path").data([data]).enter() | |
| .append("path") | |
| .attr({ | |
| d: line, | |
| fill: "none", | |
| stroke: "#FF0000" | |
| }); | |
| var pathFraction = 0.217654272; | |
| var pathLength = path.node().getTotalLength(); | |
| var pointAlongPath = function(fraction) { | |
| return path.node().getPointAtLength(pathFraction * pathLength); | |
| } | |
| path.attr({ | |
| "stroke-dasharray": 1.1 * pathLength + " " + 1.1 * pathLength, | |
| "stroke-dashoffset": pathLength * (1.1 - pathFraction) | |
| }); | |
| var circle = group.append("circle") | |
| .attr({ | |
| transform: "translate(0, 0)", | |
| r: 10 | |
| }) | |
| .transition().duration(2000) | |
| .attrTween("transform", function(d, i) { | |
| console.log("tweenOuter"); | |
| return function(t) { | |
| console.log("tweenInner"); | |
| return "translate(" + [t * 100, 100] + ")"; | |
| }; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment