(x, y, r, a0, a1, ccw)
| 6136 | } |
| 6137 | } |
| 6138 | arc(x, y, r, a0, a1, ccw) { |
| 6139 | x = +x, y = +y, r = +r, ccw = !!ccw; |
| 6140 | |
| 6141 | // Is the radius negative? Error. |
| 6142 | if (r < 0) throw new Error(`negative radius: ${r}`); |
| 6143 | |
| 6144 | let dx = r * Math.cos(a0), |
| 6145 | dy = r * Math.sin(a0), |
| 6146 | x0 = x + dx, |
| 6147 | y0 = y + dy, |
| 6148 | cw = 1 ^ ccw, |
| 6149 | da = ccw ? a0 - a1 : a1 - a0; |
| 6150 | |
| 6151 | // Is this path empty? Move to (x0,y0). |
| 6152 | if (this._x1 === null) { |
| 6153 | this._append`M${x0},${y0}`; |
| 6154 | } |
| 6155 | |
| 6156 | // Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0). |
| 6157 | else if (Math.abs(this._x1 - x0) > epsilon$4 || Math.abs(this._y1 - y0) > epsilon$4) { |
| 6158 | this._append`L${x0},${y0}`; |
| 6159 | } |
| 6160 | |
| 6161 | // Is this arc empty? We’re done. |
| 6162 | if (!r) return; |
| 6163 | |
| 6164 | // Does the angle go the wrong way? Flip the direction. |
| 6165 | if (da < 0) da = da % tau$3 + tau$3; |
| 6166 | |
| 6167 | // Is this a complete circle? Draw two arcs to complete the circle. |
| 6168 | if (da > tauEpsilon) { |
| 6169 | this._append`A${r},${r},0,1,${cw},${x - dx},${y - dy}A${r},${r},0,1,${cw},${this._x1 = x0},${this._y1 = y0}`; |
| 6170 | } |
| 6171 | |
| 6172 | // Is this arc non-empty? Draw an arc! |
| 6173 | else if (da > epsilon$4) { |
| 6174 | this._append`A${r},${r},0,${+(da >= pi$2)},${cw},${this._x1 = x + r * Math.cos(a1)},${this._y1 = y + r * Math.sin(a1)}`; |
| 6175 | } |
| 6176 | } |
| 6177 | rect(x, y, w, h) { |
| 6178 | this._append`M${this._x0 = this._x1 = +x},${this._y0 = this._y1 = +y}h${w = +w}v${+h}h${-w}Z`; |
| 6179 | } |
no outgoing calls
no test coverage detected