-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Here's the sketch:
This is the offending pathdata:
new paper.Path("M86.41 449.42a22.39 22.39 0 0128.69-6.59c17.8 9.54 46.13 23.67 67.23 29.67 25.8 7.29 73.27 24.36 93.21 31.62a7.39 7.39 0 009.91-6.44c1-15 2.86-43.37 2.84-57.65 0-32.85 0-21.6 3.38-55.66 1.67-16.72 9.39-45.22 57.75-74.63 21.6-13.13 39.48-8 52.67 1.68-13.31-14.77-35.33-29.15-63.78-11.85-48.35 29.4-56.08 57.91-57.75 74.63-3.4 34.06-3.43 22.81-3.38 55.66 0 20-3.54 67.47-3.54 67.47s-69.19-25.61-102.42-35S86.9 423.2 86.9 423.2l-4.69 22.67s-3-2.33 4.15 3.54z")
EDIT: Seems like the importing pathData function is not very stable? I am getting this error on about half of the non-trivial path data items I'm trying to import. Here's another one:
new paper.Path("M179.536 51.685c3.163-.518 11.68-.875 13.25-.875 1.004 0 2.092.23 2.687-.692.486-.755.308-2.031.453-2.907.17-1.018.409-2.022.651-3.024.69-2.85 1.733-5.562 3.192-8.108 2.738-4.777 6.75-8.519 11.814-10.696 5.593-2.404 11.921-2.955 17.937-2.467 6.437.522 12.264 2.647 18.342 4.646 5.792 1.906 11.858 2.656 17.916 1.726 6.104-.938 10.715-4.246 15.863-7.386 5.27-3.214 11.293-5.316 17.524-4.833 5.815.451 11.176 2.853 15.985 6.06 4.5 3.002 8.212 6.613 10.308 11.695 2.255 5.467 2.253 11.468-1.455 16.3-5.375 7.003-15.353 8.814-23.654 8.634a45.193 45.193 0 01-14.05-2.575c-6.046-2.127-11.27-5.73-16.926-8.655-2.654-1.372-5.398-2.5-8.274-3.311-2.79-.788-5.539-1.15-8.065.536-2.673 1.784-5.068 3.536-8.126 4.652-2.934 1.071-6.04 1.67-9.166 1.646-6.08-.047-12.075-1.942-17.98-3.21-4.816-1.035-9.97-2.067-14.88-1.072-2.048.415-5.04 1.272-5.78 3.401 12.454 2.257 17.345 17.66 13.834 28.967-1.895 6.103-13.286 13.237-17.715 10.029-2.806-2.033-1.102-4.701 0-6.463 2.111-3.373 2.834-7.706-1.073-10.055-3.37-2.026-6.913 2.785-6.98 2.78-.926-.074-8.928-4.6-14.442-11.204-5.44.323-6.265-3.264-4.966-6.197 1.299-2.933 9.406-6.625 13.776-7.342z")
EDIT: Ok, guess it's because the # of arguments for the arc commands are not 7. For example, it seems to be choking at: a45.193 45.193 0 01-14.05-2.575
However, browsers are rendering this just fine, and seems like SVG tools are exporting arc commands with less than 7 arguments, including illustrator. Is there a possible workaround here?
EDIT: Ok, I see what's happening. The large arc flag and sweep flags are concatenated without a space between them by some programs including illustrator. I.e. the 01
in a45.193 45.193 0 01-14.05-2.575
. Browsers seem to understand this and parse each of those parameters individually, but paper understands them as a single value and doesn't split them.
Related to #1808, which renders 'correctly' in browsers, but chokes in paperjs. Seems like the way browsers handle this one is even more bizarre: a150 150 0 011.593 9.98
, it will eagerly match digits to fill the sweep and arc flags, so that command is actually interpreted as a 150 150 0 0 1 .593 9.98
. Think the way to fix this would be by fixing the very complicated regex here: part.match(/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g);
not sure if I'm up for it..