dompdf/php-svg-lib

Path arc that returns to it's starting point fails with division-by-zero warning

bsweeney opened this issue · 3 comments

When attempting to draw a path with an arc segment that returns to its starting point the following warning is logged:

Division by zero in php-svg-lib/src/Svg/Tag/Path.php on line 447

The following SVG will cause the warning:

<svg version="1.1" width="120" height="120" xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink">
    <path fill="#45b7cd"
          d="M 85 60 A 25 25 0 1 0 85 60 z"/>
</svg>

The following is OK:

<svg version="1.1" width="120" height="120" xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink">
    <path fill="#45b7cd"
          d="M 84 60 A 25 25 0 1 0 85 60 z"/>
</svg>

Previously reported in #3, #61

Same issue here, when we suppose to fix this?

Bug is still present as of version 0.3.4.

I guess one question is: what is the best way to handle this? As indicated in the MDN tutorial for paths:

Complete circles and ellipses are the only shapes that SVG arcs have trouble drawing. Because the start and end points for any path going around a circle are the same point, there are an infinite number of circles that could be chosen, and the actual path is undefined.

I did some limited testing and browsers just ignore these paths. Which is the resolution I'm inclined to support.