To load and draw a SVG at run-time, create the SVG document and the SVG Image:
Delphi
|
SVGDoc := TRSSVGDocument.Create(Self);
SVGDoc.Filename := 'c:\MySVG.svg';
SVGImage := TRSSVGImage.Create(Self);
SVGImage.Parent := Self;
SVGImage.SVGDocument := SVGDoc;
|
At design-time, you would:
• Drop an SVG document component on your form ( RSSVGCtrls.TRSSVGDocument for VCL, TRSFMXSVGDocument for FMX) • Set the TRS[FMX]SVGDocument.Filename property to the SVG file. Alternatively, you can directly paste the SVG into the Lines property (warning: Delphi's TStrings editor will truncate long lines causing problems with some SVG text) • Drop a TRSSVGImage component on the form • Connect the TRSSVGImage.SVGDocument to the RSSVGDocument1 (VCL) or RSFMXSVGDocument1 (FMX) • Optionally, if you only want to display one branch of the SVG document, you can set the TRSSVGImage.SVGRoot property to the SVG element you want to display. If the SVGRoot is not empty and it does not equal any SVG element in the document, nothing is displayed. |