@@ -52,11 +52,11 @@ bool Drawable::parseSVG (const File& svgFile)
5252 }
5353 }
5454
55- auto width = svgRoot->getDoubleAttribute (" width" );
56- size.setWidth (width == 0.0 ? viewBox.getWidth () : width);
55+ auto width = svgRoot->getFloatAttribute (" width" );
56+ size.setWidth (width == 0 .0f ? viewBox.getWidth () : width);
5757
58- auto height = svgRoot->getDoubleAttribute (" height" );
59- size.setHeight (height == 0.0 ? viewBox.getHeight () : height);
58+ auto height = svgRoot->getFloatAttribute (" height" );
59+ size.setHeight (height == 0 .0f ? viewBox.getHeight () : height);
6060
6161 // ViewBox transform is now calculated at render-time based on actual target area
6262 YUP_DBG (" Parse complete - viewBox: " << viewBox.toString () << " size: " << size.getWidth () << " x" << size.getHeight ());
@@ -414,10 +414,10 @@ bool Drawable::parseElement (const XmlElement& element, bool parentIsRoot, Affin
414414 e->reference = href.substring (1 );
415415
416416 // Handle x,y positioning for use elements (SVG spec requirement)
417- auto x = element.getDoubleAttribute (" x" );
418- auto y = element.getDoubleAttribute (" y" );
417+ auto x = element.getFloatAttribute (" x" );
418+ auto y = element.getFloatAttribute (" y" );
419419 AffineTransform useTransform;
420- if (x != 0.0 || y != 0.0 )
420+ if (x != 0 .0f || y != 0 .0f )
421421 useTransform = AffineTransform::translation (x, y);
422422
423423 currentTransform = parseTransform (element, currentTransform, *e);
@@ -435,10 +435,10 @@ bool Drawable::parseElement (const XmlElement& element, bool parentIsRoot, Affin
435435 }
436436 else if (element.hasTagName (" ellipse" ))
437437 {
438- auto cx = element.getDoubleAttribute (" cx" );
439- auto cy = element.getDoubleAttribute (" cy" );
440- auto rx = element.getDoubleAttribute (" rx" );
441- auto ry = element.getDoubleAttribute (" ry" );
438+ auto cx = element.getFloatAttribute (" cx" );
439+ auto cy = element.getFloatAttribute (" cy" );
440+ auto rx = element.getFloatAttribute (" rx" );
441+ auto ry = element.getFloatAttribute (" ry" );
442442
443443 auto path = Path ();
444444 path.addCenteredEllipse (cx, cy, rx, ry);
@@ -449,9 +449,9 @@ bool Drawable::parseElement (const XmlElement& element, bool parentIsRoot, Affin
449449 }
450450 else if (element.hasTagName (" circle" ))
451451 {
452- auto cx = element.getDoubleAttribute (" cx" );
453- auto cy = element.getDoubleAttribute (" cy" );
454- auto r = element.getDoubleAttribute (" r" );
452+ auto cx = element.getFloatAttribute (" cx" );
453+ auto cy = element.getFloatAttribute (" cy" );
454+ auto r = element.getFloatAttribute (" r" );
455455
456456 auto path = Path ();
457457 path.addCenteredEllipse (cx, cy, r, r);
@@ -462,19 +462,19 @@ bool Drawable::parseElement (const XmlElement& element, bool parentIsRoot, Affin
462462 }
463463 else if (element.hasTagName (" rect" ))
464464 {
465- auto x = element.getDoubleAttribute (" x" );
466- auto y = element.getDoubleAttribute (" y" );
467- auto width = element.getDoubleAttribute (" width" );
468- auto height = element.getDoubleAttribute (" height" );
469- auto rx = element.getDoubleAttribute (" rx" );
470- auto ry = element.getDoubleAttribute (" ry" );
465+ auto x = element.getFloatAttribute (" x" );
466+ auto y = element.getFloatAttribute (" y" );
467+ auto width = element.getFloatAttribute (" width" );
468+ auto height = element.getFloatAttribute (" height" );
469+ auto rx = element.getFloatAttribute (" rx" );
470+ auto ry = element.getFloatAttribute (" ry" );
471471
472472 auto path = Path ();
473- if (rx > 0.0 || ry > 0.0 )
473+ if (rx > 0 .0f || ry > 0 .0f )
474474 {
475- if (rx == 0.0 )
475+ if (rx == 0 .0f )
476476 rx = ry;
477- if (ry == 0.0 )
477+ if (ry == 0 .0f )
478478 ry = rx;
479479
480480 path.addRoundedRectangle (x, y, width, height, rx, ry, rx, ry);
@@ -491,10 +491,10 @@ bool Drawable::parseElement (const XmlElement& element, bool parentIsRoot, Affin
491491 }
492492 else if (element.hasTagName (" line" ))
493493 {
494- auto x1 = element.getDoubleAttribute (" x1" );
495- auto y1 = element.getDoubleAttribute (" y1" );
496- auto x2 = element.getDoubleAttribute (" x2" );
497- auto y2 = element.getDoubleAttribute (" y2" );
494+ auto x1 = element.getFloatAttribute (" x1" );
495+ auto y1 = element.getFloatAttribute (" y1" );
496+ auto x2 = element.getFloatAttribute (" x2" );
497+ auto y2 = element.getFloatAttribute (" y2" );
498498
499499 auto path = Path ();
500500 path.startNewSubPath (x1, y1);
@@ -552,8 +552,8 @@ bool Drawable::parseElement (const XmlElement& element, bool parentIsRoot, Affin
552552 }
553553 else if (element.hasTagName (" text" ))
554554 {
555- auto x = ( float ) element.getDoubleAttribute (" x" );
556- auto y = ( float ) element.getDoubleAttribute (" y" );
555+ float x = element.getFloatAttribute (" x" );
556+ float y = element.getFloatAttribute (" y" );
557557 e->textPosition = Point<float > (x, y);
558558
559559 e->text = element.getAllSubText ();
@@ -562,8 +562,8 @@ bool Drawable::parseElement (const XmlElement& element, bool parentIsRoot, Affin
562562 if (fontFamily.isNotEmpty ())
563563 e->fontFamily = fontFamily;
564564
565- auto fontSize = element.getDoubleAttribute (" font-size" );
566- if (fontSize > 0.0 )
565+ float fontSize = element.getFloatAttribute (" font-size" );
566+ if (fontSize > 0 .0f )
567567 e->fontSize = fontSize;
568568
569569 String textAnchor = element.getStringAttribute (" text-anchor" );
@@ -575,10 +575,10 @@ bool Drawable::parseElement (const XmlElement& element, bool parentIsRoot, Affin
575575 }
576576 else if (element.hasTagName (" image" ))
577577 {
578- auto x = element.getDoubleAttribute (" x" );
579- auto y = element.getDoubleAttribute (" y" );
580- auto width = element.getDoubleAttribute (" width" );
581- auto height = element.getDoubleAttribute (" height" );
578+ auto x = element.getFloatAttribute (" x" );
579+ auto y = element.getFloatAttribute (" y" );
580+ auto width = element.getFloatAttribute (" width" );
581+ auto height = element.getFloatAttribute (" height" );
582582
583583 e->imageBounds = Rectangle<float > (x, y, width, height);
584584
@@ -689,12 +689,12 @@ void Drawable::parseStyle (const XmlElement& element, const AffineTransform& cur
689689 else if (strokeCap == " butt" )
690690 e.strokeCap = StrokeCap::Butt;
691691
692- float strokeWidth = element.getDoubleAttribute (" stroke-width" , -1.0 );
693- if (strokeWidth > 0.0 )
692+ float strokeWidth = element.getFloatAttribute (" stroke-width" , -1 .0f );
693+ if (strokeWidth > 0 .0f )
694694 e.strokeWidth = strokeWidth;
695695
696- float opacity = element.getDoubleAttribute (" opacity" , -1.0 );
697- if (opacity >= 0.0 && opacity <= 1.0 )
696+ float opacity = element.getFloatAttribute (" opacity" , -1 .0f );
697+ if (opacity >= 0 .0f && opacity <= 1 .0f )
698698 e.opacity = opacity;
699699
700700 String clipPath = element.getStringAttribute (" clip-path" );
@@ -731,13 +731,13 @@ void Drawable::parseStyle (const XmlElement& element, const AffineTransform& cur
731731 e.strokeDashOffset = parseUnit (dashOffset);
732732
733733 // Parse fill-opacity
734- float fillOpacity = element.getDoubleAttribute (" fill-opacity" , -1.0 );
735- if (fillOpacity >= 0.0 && fillOpacity <= 1.0 )
734+ float fillOpacity = element.getFloatAttribute (" fill-opacity" , -1 .0f );
735+ if (fillOpacity >= 0 .0f && fillOpacity <= 1 .0f )
736736 e.fillOpacity = fillOpacity;
737737
738738 // Parse stroke-opacity
739- float strokeOpacity = element.getDoubleAttribute (" stroke-opacity" , -1.0 );
740- if (strokeOpacity >= 0.0 && strokeOpacity <= 1.0 )
739+ float strokeOpacity = element.getFloatAttribute (" stroke-opacity" , -1 .0f );
740+ if (strokeOpacity >= 0 .0f && strokeOpacity <= 1 .0f )
741741 e.strokeOpacity = strokeOpacity;
742742
743743 // Parse fill-rule
@@ -916,20 +916,20 @@ void Drawable::parseGradient (const XmlElement& element)
916916 if (element.hasTagName (" linearGradient" ))
917917 {
918918 gradient->type = Gradient::Linear;
919- gradient->start = { ( float ) element.getDoubleAttribute (" x1" ), ( float ) element.getDoubleAttribute (" y1" ) };
920- gradient->end = { ( float ) element.getDoubleAttribute (" x2" ), ( float ) element.getDoubleAttribute (" y2" ) };
919+ gradient->start = { element.getFloatAttribute (" x1" ), element.getFloatAttribute (" y1" ) };
920+ gradient->end = { element.getFloatAttribute (" x2" ), element.getFloatAttribute (" y2" ) };
921921
922922 YUP_DBG (" Linear gradient - start: (" << gradient->start .getX () << " , " << gradient->start .getY () << " ) end: (" << gradient->end .getX () << " , " << gradient->end .getY () << " )" );
923923 }
924924 else if (element.hasTagName (" radialGradient" ))
925925 {
926926 gradient->type = Gradient::Radial;
927- gradient->center = { ( float ) element.getDoubleAttribute (" cx" ), ( float ) element.getDoubleAttribute (" cy" ) };
928- gradient->radius = element.getDoubleAttribute (" r" );
927+ gradient->center = { element.getFloatAttribute (" cx" ), element.getFloatAttribute (" cy" ) };
928+ gradient->radius = element.getFloatAttribute (" r" );
929929
930- auto fx = element.getDoubleAttribute (" fx" , gradient->center .getX ());
931- auto fy = element.getDoubleAttribute (" fy" , gradient->center .getY ());
932- gradient->focal = { ( float ) fx, ( float ) fy };
930+ auto fx = element.getFloatAttribute (" fx" , gradient->center .getX ());
931+ auto fy = element.getFloatAttribute (" fy" , gradient->center .getY ());
932+ gradient->focal = { fx, fy };
933933
934934 YUP_DBG (" Radial gradient - center: (" << gradient->center .getX () << " , " << gradient->center .getY () << " ) radius: " << gradient->radius );
935935 }
@@ -962,11 +962,11 @@ void Drawable::parseGradient (const XmlElement& element)
962962 if (child->hasTagName (" stop" ))
963963 {
964964 GradientStop stop;
965- stop.offset = child->getDoubleAttribute (" offset" );
965+ stop.offset = child->getFloatAttribute (" offset" );
966966
967967 // First try to get stop-color from attributes
968968 String stopColor = child->getStringAttribute (" stop-color" );
969- float stopOpacity = child->getDoubleAttribute (" stop-opacity" , 1.0 );
969+ float stopOpacity = child->getFloatAttribute (" stop-opacity" , 1 .0f );
970970
971971 // If not found in attributes, parse from CSS style
972972 if (stopColor.isEmpty ())
@@ -1183,20 +1183,20 @@ void Drawable::parseClipPath (const XmlElement& element)
11831183 }
11841184 else if (child->hasTagName (" rect" ))
11851185 {
1186- auto x = child->getDoubleAttribute (" x" );
1187- auto y = child->getDoubleAttribute (" y" );
1188- auto width = child->getDoubleAttribute (" width" );
1189- auto height = child->getDoubleAttribute (" height" );
1186+ auto x = child->getFloatAttribute (" x" );
1187+ auto y = child->getFloatAttribute (" y" );
1188+ auto width = child->getFloatAttribute (" width" );
1189+ auto height = child->getFloatAttribute (" height" );
11901190
11911191 auto path = Path ();
11921192 path.addRectangle (x, y, width, height);
11931193 clipElement->path = std::move (path);
11941194 }
11951195 else if (child->hasTagName (" circle" ))
11961196 {
1197- auto cx = child->getDoubleAttribute (" cx" );
1198- auto cy = child->getDoubleAttribute (" cy" );
1199- auto r = child->getDoubleAttribute (" r" );
1197+ auto cx = child->getFloatAttribute (" cx" );
1198+ auto cy = child->getFloatAttribute (" cy" );
1199+ auto r = child->getFloatAttribute (" r" );
12001200
12011201 auto path = Path ();
12021202 path.addCenteredEllipse (cx, cy, r, r);
0 commit comments