Jump to content
Darian Miller

SVG graphics in FMX applications

Recommended Posts

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×