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

Two.Utils.read.path throws an error #698

Open abdallahz3 opened 1 year ago

abdallahz3 commented 1 year ago

Describe the bug I'm trying to create a twojs path from an svg path string

To Reproduce Steps to reproduce the behavior: var 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'; var heart = Two.Utils.read.path(d); two.add(heart);

trying the above code throws this error

caught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. at Object.applySvgAttributes (

Expected behavior twojs path created from an svg path

Screenshots

image

Environment (please select one):

jonobr1 commented 1 year ago

Thanks for reporting. This PR fixes that issue: https://github.com/jonobr1/two.js/pull/699

abdallahz3 commented 1 year ago

that was quick, Thanks a lot @jonobr1

not sure how to test this change, I checked Versions of two.js on npm website, but don't see a new version

jonobr1 commented 1 year ago

A new package isn't up, but you can npm install the git repo directly