MCPcopy Create free account
hub / github.com/microsoft/SandDance / vg_trail

Function vg_trail

docs/app/js/sanddance-app.js:121745–121812  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

121743 return rectangle1;
121744}
121745function vg_trail() {
121746 var x8, y7, size, defined, context17 = null, ready, x1, y1, r1;
121747 function point1(x2, y2, w2) {
121748 const r2 = w2 / 2;
121749 if (ready) {
121750 var ux = y1 - y2, uy = x2 - x1;
121751 if (ux || uy) {
121752 // get normal vector
121753 var ud = Math.sqrt(ux * ux + uy * uy), rx = (ux /= ud) * r1, ry = (uy /= ud) * r1, t = Math.atan2(uy, ux); // draw segment
121754 context17.moveTo(x1 - rx, y1 - ry);
121755 context17.lineTo(x2 - ux * r2, y2 - uy * r2);
121756 context17.arc(x2, y2, r2, t - Math.PI, t);
121757 context17.lineTo(x1 + rx, y1 + ry);
121758 context17.arc(x1, y1, r1, t, t + Math.PI);
121759 } else context17.arc(x2, y2, r2, 0, Tau);
121760 context17.closePath();
121761 } else ready = 1;
121762 x1 = x2;
121763 y1 = y2;
121764 r1 = r2;
121765 }
121766 function trail1(data) {
121767 var i, n = data.length, d, defined0 = false, buffer;
121768 if (context17 == null) context17 = buffer = (0, _d3Path.path)();
121769 for(i = 0; i <= n; ++i){
121770 if (!(i < n && defined(d = data[i], i, data)) === defined0) {
121771 if (defined0 = !defined0) ready = 0;
121772 }
121773 if (defined0) point1(+x8(d, i, data), +y7(d, i, data), +size(d, i, data));
121774 }
121775 if (buffer) {
121776 context17 = null;
121777 return buffer + "" || null;
121778 }
121779 }
121780 trail1.x = function(_) {
121781 if (arguments.length) {
121782 x8 = _;
121783 return trail1;
121784 } else return x8;
121785 };
121786 trail1.y = function(_) {
121787 if (arguments.length) {
121788 y7 = _;
121789 return trail1;
121790 } else return y7;
121791 };
121792 trail1.size = function(_) {
121793 if (arguments.length) {
121794 size = _;
121795 return trail1;
121796 } else return size;
121797 };
121798 trail1.defined = function(_) {
121799 if (arguments.length) {
121800 defined = _;
121801 return trail1;
121802 } else return defined;

Callers 1

sanddance-app.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected