Darian Miller 366 Posted November 19, 2019 I started up a new blog recently and just added a quick article on using SVG with TPath. I didn't know how easy it was to do in FireMonkey: https://www.ideasawakened.com/post/simple-svg-images-in-delphi-applications 1 2 Share this post Link to post
Rollo62 539 Posted November 20, 2019 Thanks for the great article, also me I like TPath, TPathData a lot, which gives much more flexibility in UI design. 1. In your list of alternatives you missed HtmlComponents, which also include a quite powerful SVG engine. 2. TPathData is really a great tool, but I found out a while ago that it doesn't seems to support all SVG curve types yet. It seems to support the cubic bezier curves, like this from string to internal format: 'C': begin CurvePoint1 := GetPointFromString(PathString, Pos); CurvePoint2 := GetPointFromString(PathString, Pos); CurveTo(CurvePoint1, CurvePoint2, GetPointFromString(PathString, Pos)); while HasRelativeOffset(PathString, Pos) do begin CurvePoint1 := GetPointFromString(PathString, Pos); CurvePoint2 := GetPointFromString(PathString, Pos); CurveTo(CurvePoint1, CurvePoint2, GetPointFromString(PathString, Pos)); end; end; 'c': begin CurvePoint1 := GetPointFromString(PathString, Pos); CurvePoint2 := GetPointFromString(PathString, Pos); CurveToRel(CurvePoint1, CurvePoint2, GetPointFromString(PathString, Pos)); while HasRelativeOffset(PathString, Pos) do begin CurvePoint1 := GetPointFromString(PathString, Pos); CurvePoint2 := GetPointFromString(PathString, Pos); CurveToRel(CurvePoint1, CurvePoint2, GetPointFromString(PathString, Pos)); end; end; But the quadratic bezier curves seems not be implemented right now: 'Q', 'q': begin GetPointFromString(PathString, Pos); GetPointFromString(PathString, Pos); end; 'T', 't': GetPointFromString(PathString, Pos); Maybe this is a feature or a bug, I hope you have some more insight about the SVG details, since you delved more deeply into it. My original thought was that maybe quadratic and cubic bezier curves are compatible, and I could replace one with the other, but I had no time yet to proof this. Why else should Embarcadero miss these implementations ? However, I totally agree and can only recommend to use more SVG via TPath in your apps. Advantages are for me: - very likely less memory footprint than many bitmaps of same object (x1.0, x2.0, x3.0, red version, green version, ...) - can change stroke/fill color on demand - can be dynamically changed, giving a kind of animation Share this post Link to post