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

Function _path

src/lib/angles.js:106–175  ·  view source on GitHub ↗
(r0, r1, a0, a1, cx, cy, isClosed)

Source from the content-addressed store, hash-verified

104
105// common to pathArc, pathSector and pathAnnulus
106function _path(r0, r1, a0, a1, cx, cy, isClosed) {
107 cx = cx || 0;
108 cy = cy || 0;
109
110 var isCircle = isFullCircle([a0, a1]);
111 var aStart, aMid, aEnd;
112 var rStart, rEnd;
113
114 if(isCircle) {
115 aStart = 0;
116 aMid = PI;
117 aEnd = twoPI;
118 } else {
119 if(a0 < a1) {
120 aStart = a0;
121 aEnd = a1;
122 } else {
123 aStart = a1;
124 aEnd = a0;
125 }
126 }
127
128 if(r0 < r1) {
129 rStart = r0;
130 rEnd = r1;
131 } else {
132 rStart = r1;
133 rEnd = r0;
134 }
135
136 // N.B. svg coordinates here, where y increases downward
137 function pt(r, a) {
138 return [r * Math.cos(a) + cx, cy - r * Math.sin(a)];
139 }
140
141 var largeArc = Math.abs(aEnd - aStart) <= PI ? 0 : 1;
142 function arc(r, a, cw) {
143 return 'A' + [r, r] + ' ' + [0, largeArc, cw] + ' ' + pt(r, a);
144 }
145
146 var p;
147
148 if(isCircle) {
149 if(rStart === null) {
150 p = 'M' + pt(rEnd, aStart) +
151 arc(rEnd, aMid, 0) +
152 arc(rEnd, aEnd, 0) + 'Z';
153 } else {
154 p = 'M' + pt(rStart, aStart) +
155 arc(rStart, aMid, 0) +
156 arc(rStart, aEnd, 0) + 'Z' +
157 'M' + pt(rEnd, aStart) +
158 arc(rEnd, aMid, 1) +
159 arc(rEnd, aEnd, 1) + 'Z';
160 }
161 } else {
162 if(rStart === null) {
163 p = 'M' + pt(rEnd, aStart) + arc(rEnd, aEnd, 0);

Callers 3

pathArcFunction · 0.85
pathSectorFunction · 0.85
pathAnnulusFunction · 0.85

Calls 3

isFullCircleFunction · 0.85
ptFunction · 0.85
arcFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…