MCPcopy Index your code
hub / github.com/plotly/plotly.js / align

Function align

src/components/drawing/symbol_defs.js:721–813  ·  view source on GitHub ↗
(angle, standoff, path)

Source from the content-addressed store, hash-verified

719var lastAngle, lastStandoff;
720
721function align(angle, standoff, path) {
722 if((!angle || angle % 360 === 0) && !standoff) return path;
723
724 if(
725 lastAngle === angle &&
726 lastStandoff === standoff &&
727 lastPathIn === path
728 ) return lastPathOut;
729
730 lastAngle = angle;
731 lastStandoff = standoff;
732 lastPathIn = path;
733
734 function rotate(t, xy) {
735 var cosT = cos(t);
736 var sinT = sin(t);
737
738 var x = xy[0];
739 var y = xy[1] + (standoff || 0);
740 return [
741 x * cosT - y * sinT,
742 x * sinT + y * cosT
743 ];
744 }
745
746 var t = angle / 180 * PI;
747
748 var x = 0;
749 var y = 0;
750 var cmd = parseSvgPath(path);
751 var str = '';
752
753 for(var i = 0; i < cmd.length; i++) {
754 var cmdI = cmd[i];
755 var op = cmdI[0];
756
757 var x0 = x;
758 var y0 = y;
759
760 if(op === 'M' || op === 'L') {
761 x = +cmdI[1];
762 y = +cmdI[2];
763 } else if(op === 'm' || op === 'l') {
764 x += +cmdI[1];
765 y += +cmdI[2];
766 } else if(op === 'H') {
767 x = +cmdI[1];
768 } else if(op === 'h') {
769 x += +cmdI[1];
770 } else if(op === 'V') {
771 y = +cmdI[1];
772 } else if(op === 'v') {
773 y += +cmdI[1];
774 } else if(op === 'A') {
775 x = +cmdI[1];
776 y = +cmdI[2];
777
778 var E = rotate(t, [+cmdI[6], +cmdI[7]]);

Callers 2

symbol_defs.jsFile · 0.85

Calls 1

rotateFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…