@@ -500,11 +500,10 @@ proc parseSvgElement(
500500 raise newException (PixieError , " Unsupported SVG tag: " & node.tag)
501501
502502proc parseSvg * (
503- data: string | XmlNode , width = 0 , height = 0
503+ root: XmlNode , width = 0 , height = 0
504504): Svg {.raises : [PixieError ].} =
505505 # # Parse SVG XML. Defaults to the SVG's view box size.
506506 try :
507- let root = parseXml (data)
508507 if root.tag != " svg" :
509508 failInvalid ()
510509
@@ -521,7 +520,7 @@ proc parseSvg*(
521520
522521 if viewBoxMinX != 0 or viewBoxMinY != 0 :
523522 let viewBoxMin = vec2 (- viewBoxMinX.float32 , - viewBoxMinY.float32 )
524- rootprops .transform = rootprops .transform * translate (viewBoxMin)
523+ rootProps .transform = rootProps .transform * translate (viewBoxMin)
525524
526525 result = Svg ()
527526
@@ -535,7 +534,7 @@ proc parseSvg*(
535534 let
536535 scaleX = width.float32 / viewBoxWidth.float32
537536 scaleY = height.float32 / viewBoxHeight.float32
538- rootprops .transform = rootprops .transform * scale (vec2 (scaleX, scaleY))
537+ rootProps .transform = rootProps .transform * scale (vec2 (scaleX, scaleY))
539538
540539 var propertiesStack = @ [rootProps]
541540 for node in root.items:
@@ -545,6 +544,16 @@ proc parseSvg*(
545544 except :
546545 raise currentExceptionAsPixieError ()
547546
547+ proc parseSvg * (data: string , width = 0 , height = 0 ): Svg {.raises : [PixieError ].} =
548+ # # Parse SVG data. Defaults to the SVG's view box size.
549+ try :
550+ let root = parseXml (data)
551+ result = root.parseSvg (width, height)
552+ except PixieError as e:
553+ raise e
554+ except :
555+ raise currentExceptionAsPixieError ()
556+
548557proc newImage * (svg: Svg ): Image {.raises : [PixieError ].} =
549558 # # Render SVG and return the image.
550559 result = newImage (svg.width, svg.height)
0 commit comments