Skip to content

matrix elements with small numbers fail to parse; style not parsed #138

Open
@zkamvar

Description

@zkamvar

I'm really enjoying working with Excalidraw and wanted to import my org's logo using this tool, but ran into an issue when I tried to paste the raw SVG:

<svg viewBox="23.011598587036133 176.38101196289062 76.86479759216309 79.23809814453125" width="76.86479759216309" height="79.23809814453125" xmlns="http://www.w3.org/2000/svg">
  <path id="path2" style="fill:#071159;fill-rule:evenodd" d="m 60.4089,220.1395 -0.609,-15.6219 13.481,-8.4941 13.6126,7.2951 0.692,16.0431 -13.481,8.4935 z" transform="matrix(1, 0, 0, 1, 3.552713678800501e-15, 0)"/>
  <path id="path4" style="fill:#071159;fill-rule:evenodd" d="m 33.6628,217.112 -0.0823,-22.4502 29.2906,-18.2808 14.0091,8.3629 c -10.1028,6.5645 -14.7455,9.3309 -24.9875,15.6991 l -0.1926,5.9751 z" transform="matrix(1, 0, 0, 1, 3.552713678800501e-15, 0)"/>
  <path id="path6" style="fill:#071159;fill-rule:evenodd" d="m 35.0548,248.4071 -12.0432,-19.0814 28.7863,-16.8447 1.1557,12.3346 10.7928,5.589 z" transform="matrix(1, 0, 0, 1, 3.552713678800501e-15, 0)"/>
  <path id="path8" style="fill:#071159;fill-rule:evenodd" d="m 50.128,245.2642 19.919,10.3549 29.8294,-18.2487 -1.8935,-15.6419 c -10.3375,6.1835 -14.3477,8.7856 -24.6876,14.9664 l -5.3995,-2.5663 z" transform="matrix(1, 0, 0, 1, 3.552713678800501e-15, 0)"/>
</svg>

I ended up with an error that said Failed to construct 'DOMMatrix': Failed to parse 'matrix(1, 0, 0, 1, 3.552713678800501e, -15, 0)'.

It looks like the parser does not know how to handle scientific notation and treated the fifth number as a string and a negative number.

To be fair, I'm not sure what the transform is doing there because I was able to remove it and get the output (albiet without styling):

<svg viewBox="23.011598587036133 176.38101196289062 76.86479759216309 79.23809814453125" width="76.86479759216309" height="79.23809814453125" xmlns="http://www.w3.org/2000/svg">
  <path id="path2" style="fill:#071159;fill-rule:evenodd" d="m 60.4089,220.1395 -0.609,-15.6219 13.481,-8.4941 13.6126,7.2951 0.692,16.0431 -13.481,8.4935 z"/>
  <path id="path4" style="fill:#071159;fill-rule:evenodd" d="m 33.6628,217.112 -0.0823,-22.4502 29.2906,-18.2808 14.0091,8.3629 c -10.1028,6.5645 -14.7455,9.3309 -24.9875,15.6991 l -0.1926,5.9751 z"/>
  <path id="path6" style="fill:#071159;fill-rule:evenodd" d="m 35.0548,248.4071 -12.0432,-19.0814 28.7863,-16.8447 1.1557,12.3346 10.7928,5.589 z"/>
  <path id="path8" style="fill:#071159;fill-rule:evenodd" d="m 50.128,245.2642 19.919,10.3549 29.8294,-18.2487 -1.8935,-15.6419 c -10.3375,6.1835 -14.3477,8.7856 -24.6876,14.9664 l -5.3995,-2.5663 z"/>
</svg>

output:

{"type":"excalidraw","version":2,"source":"https://excalidraw.com","elements":[{"id":"7cNg2xMynlqFXedVMiGqB","x":60.40890121459961,"y":220.13949584960938,"strokeColor":"#00000000","backgroundColor":"black","fillStyle":"solid","strokeWidth":0,"strokeStyle":"solid","strokeSharpness":"sharp","roughness":0,"opacity":100,"width":27.785602569580078,"height":31.831695556640625,"angle":0,"seed":2053904339,"version":0,"versionNonce":0,"isDeleted":false,"groupIds":["IAPSzHol2e7LJBD4BRrYX"],"boundElementIds":null,"type":"draw","points":[[0,0],[-0.6090011596679688,-15.621902465820312],[12.871997833251953,-24.115997314453125],[26.484600067138672,-16.820892333984375],[27.17660140991211,-0.777801513671875],[13.695598602294922,7.7156982421875],[0,0]]},{"id":"LiJIpTUyf81j6wPRMrgqr","x":33.66279983520508,"y":217.11199951171875,"strokeColor":"#00000000","backgroundColor":"black","fillStyle":"solid","strokeWidth":0,"strokeStyle":"solid","strokeSharpness":"sharp","roughness":0,"opacity":100,"width":43.29970169067383,"height":40.73100280761719,"angle":0,"seed":1138770653,"version":0,"versionNonce":0,"isDeleted":false,"groupIds":["N4W0aNww_gDeH12Whe1FH"],"boundElementIds":null,"type":"draw","points":[[0,0],[-0.08229827880859375,-22.4501953125],[29.208301544189453,-40.73100280761719],[43.217403411865234,-32.36810302734375],[43.217403411865234,-32.36810302734375],[39.66318893432617,-30.069992065429688],[36.491268157958984,-28.041244506835938],[33.572017669677734,-26.19512939453125],[30.77585220336914,-24.444931030273438],[27.973155975341797,-22.703948974609375],[25.03433609008789,-20.88543701171875],[21.829784393310547,-18.902694702148438],[18.229900360107422,-16.66900634765625],[18.03730010986328,-10.693893432617188],[0,0]]},{"id":"ZkhPYiF-nS9DcjIQhThR5","x":35.0547981262207,"y":248.4071044921875,"strokeColor":"#00000000","backgroundColor":"black","fillStyle":"solid","strokeWidth":0,"strokeStyle":"solid","strokeSharpness":"sharp","roughness":0,"opacity":100,"width":40.734798431396484,"height":35.92610168457031,"angle":0,"seed":459253107,"version":0,"versionNonce":0,"isDeleted":false,"groupIds":["p_xtVBqPPQKjdKKr12tq4"],"boundElementIds":null,"type":"draw","points":[[0,0],[-12.043197631835938,-19.081405639648438],[16.74310302734375,-35.92610168457031],[17.8988037109375,-23.591506958007812],[28.691600799560547,-18.00250244140625],[0,0]]},{"id":"4KD45dcffUP4zW95pBBR8","x":50.12799835205078,"y":245.2642059326172,"strokeColor":"#00000000","backgroundColor":"black","fillStyle":"solid","strokeWidth":0,"strokeStyle":"solid","strokeSharpness":"sharp","roughness":0,"opacity":100,"width":49.74840545654297,"height":33.890594482421875,"angle":0,"seed":133029693,"version":0,"versionNonce":0,"isDeleted":false,"groupIds":["z-3mIaXGoaUY51_6lG87C"],"boundElementIds":null,"type":"draw","points":[[0,0],[19.91899871826172,10.354888916015625],[49.74840545654297,-7.893798828125],[47.85490417480469,-23.53570556640625],[47.85490417480469,-23.53570556640625],[44.250213623046875,-21.37078857421875],[41.09037780761719,-19.457717895507812],[38.227081298828125,-17.71258544921875],[35.512001037597656,-16.051498413085938],[32.79680633544922,-14.390518188476562],[29.93317413330078,-12.645782470703125],[26.772781372070312,-10.73333740234375],[23.16730499267578,-8.569305419921875],[17.767799377441406,-11.135604858398438],[0,0]]}]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions