fskpf/svg2roughjs

Out of memory when not randomizing hatching

jroessel opened this issue · 1 comments

Interestingly with an image that may not even have any fills: https://upload.wikimedia.org/wikipedia/commons/9/99/Soyuz-T_drawing.svg

fskpf commented

Reduced it to

<svg xmlns="http://www.w3.org/2000/svg" version="1.0" viewBox="0 0 393.2 231.5">
  <path d="M 319.508,715.729 L 320.767,715.932 L 321.507,712.088 L 320.248,711.885 L 319.508,715.729 z" stroke="#000" stroke-width="1" transform="matrix(1.25 0 0 -1.25 -306 899.7)"/>
</svg>

which produces NaN values for the scale-factor

  if (!isIdentityTransform(svgTransform)) {
    const m = svgTransform!.matrix
    const det = m.a * m.d - m.c * m.b
    scaleFactor = Math.sqrt(det)
  }

These NaN strokeWidth values trigger an inifinite loop in roughjs.