Closed TuBui closed 3 years ago
You wouldn't work around this bug. 0 is a correct length. Return zero. Do not try to average things out of self._length == 0 then it is the case that they all equal zero and the average is zero. The other problem here is that with zero lengths it means calculation of your position within that path also suffers a different error for that edge condition that needs to be fixed.
path.point(0.5) gives you a different kind of crash since you're half way through 0 length.
Computing length of each path returned by svg2paths() fails when reading the following svg: https://www.dropbox.com/s/2b13vqykmvid0eg/13865.svg?dl=0
Procedure to reproduce:
The error it throws:
The error seems to come from self._length being zero in path.py. It is unusual but possible as the sketch above has a path: 'M261 166 L261 166 ' which looks like a single dot on the canvas.
Adding an epsilon to self._length seems to be a workaround:
self._length = sum(lengths) + np.finfo(np.float32).eps