(element, swap)
| 196 | |
| 197 | |
| 198 | export function convertToPath(element, swap) { |
| 199 | var type = element.tagName.toLowerCase(), |
| 200 | circ = 0.552284749831, |
| 201 | data, |
| 202 | x, |
| 203 | y, |
| 204 | r, |
| 205 | ry, |
| 206 | path, |
| 207 | rcirc, |
| 208 | rycirc, |
| 209 | points, |
| 210 | w, |
| 211 | h, |
| 212 | x2, |
| 213 | x3, |
| 214 | x4, |
| 215 | x5, |
| 216 | x6, |
| 217 | y2, |
| 218 | y3, |
| 219 | y4, |
| 220 | y5, |
| 221 | y6, |
| 222 | attr; |
| 223 | |
| 224 | if (type === "path" || !element.getBBox) { |
| 225 | return element; |
| 226 | } |
| 227 | |
| 228 | path = _createPath(element, "x,y,width,height,cx,cy,rx,ry,r,x1,x2,y1,y2,points"); |
| 229 | attr = _attrToObj(element, _typeAttrs[type]); |
| 230 | |
| 231 | if (type === "rect") { |
| 232 | r = attr.rx; |
| 233 | ry = attr.ry || r; |
| 234 | x = attr.x; |
| 235 | y = attr.y; |
| 236 | w = attr.width - r * 2; |
| 237 | h = attr.height - ry * 2; |
| 238 | |
| 239 | if (r || ry) { |
| 240 | //if there are rounded corners, render cubic beziers |
| 241 | x2 = x + r * (1 - circ); |
| 242 | x3 = x + r; |
| 243 | x4 = x3 + w; |
| 244 | x5 = x4 + r * circ; |
| 245 | x6 = x4 + r; |
| 246 | y2 = y + ry * (1 - circ); |
| 247 | y3 = y + ry; |
| 248 | y4 = y3 + h; |
| 249 | y5 = y4 + ry * circ; |
| 250 | y6 = y4 + ry; |
| 251 | data = "M" + x6 + "," + y3 + " V" + y4 + " C" + [x6, y5, x5, y6, x4, y6, x4 - (x4 - x3) / 3, y6, x3 + (x4 - x3) / 3, y6, x3, y6, x2, y6, x, y5, x, y4, x, y4 - (y4 - y3) / 3, x, y3 + (y4 - y3) / 3, x, y3, x, y2, x2, y, x3, y, x3 + (x4 - x3) / 3, y, x4 - (x4 - x3) / 3, y, x4, y, x5, y, x6, y2, x6, y3].join(",") + "z"; |
| 252 | } else { |
| 253 | data = "M" + (x + w) + "," + y + " v" + h + " h" + -w + " v" + -h + " h" + w + "z"; |
| 254 | } |
| 255 | } else if (type === "circle" || type === "ellipse") { |
nothing calls this directly
no test coverage detected
searching dependent graphs…