MCPcopy Create free account
hub / github.com/SeaOfNodes/Simple / pathTweenPoints

Function pathTweenPoints

chapter18/docs/d3-graphviz.js:385–407  ·  view source on GitHub ↗
(node, d1, precision, precisionIsRelative)

Source from the content-addressed store, hash-verified

383 };
384 }
385 function pathTweenPoints(node, d1, precision, precisionIsRelative) {
386 var path0 = node;
387 var path1 = path0.cloneNode();
388 var n0 = path0.getTotalLength();
389 var n1 = (path1.setAttribute("d", d1), path1).getTotalLength();
390
391 // Uniform sampling of distance based on specified precision.
392 var distances = [0];
393 var i = 0;
394 var dt = precisionIsRelative ? precision : precision / Math.max(n0, n1);
395 while ((i += dt) < 1) {
396 distances.push(i);
397 }
398 distances.push(1);
399
400 // Compute point-interpolators at each distance.
401 var points = distances.map(function (t) {
402 var p0 = path0.getPointAtLength(t * n0);
403 var p1 = path1.getPointAtLength(t * n1);
404 return [[p0.x, p0.y], [p1.x, p1.y]];
405 });
406 return points;
407 }
408
409 function data () {
410 return this._data || null;

Callers 1

calculatePathTweenPointsFunction · 0.70

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected