jonobr1 / two.js

A renderer agnostic two-dimensional drawing api for the web.
https://two.js.org
MIT License
8.27k stars 454 forks source link

Issue 698 Read Path as Data String #699

Closed jonobr1 closed 1 year ago

jonobr1 commented 1 year ago

This patch fixes the following scenario:

const two = new Two({
  type: Two.Types.svg,
  fullscreen: true,
  autostart: true
}).appendTo(document.body);

const d = 'M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z';

const path = Two.Utils.read.path.call(two, d);
two.add(path);

By adding null checks on Two.Utils.applySvgAttributes method