SVG Canvas for FireMonkey

SVG Canvas for FireMonkey example
  • converts canvas drawing to SVG format
  • supports Windows 32, Windows 64, macOS, iOS and Android
  • available for Delphi/C++ Builder XE3 - 10.2
  • source code included in registered version
  • royalty free distribution in applications

Example

with TSvgCanvas.Create('image.svg', Canvas) do
try
  BeginScene;

  Stroke.Color := TAlphaColorRec.Red;
  Stroke.Thickness := 2;
  DrawEllipse(TRectF.Create(10, 10, 220, 120), 0.5);

  EndScene;
finally
  Free;
end;
								

API

type
  ESvgError = class(Exception)

  TSvgCanvas = class
    constructor Create(Stream: TStream; Canvas: TCanvas);
    constructor Create(const FileName: string; Canvas: TCanvas);

    class procedure Lock;
    class procedure Unlock;

    function AlignToPixel(const Value: TPointF): TPointF;
    function AlignToPixel(const Rect: TRectF): TRectF;
    function AlignToPixelHorizontally(const Value: Single): Single;
    function AlignToPixelVertically(const Value: Single): Single;
    function BeginScene(AClipRects: PClipRects = nil; AContextHandle: THandle = 0): Boolean;
    procedure Clear(const Color: TAlphaColor);
    procedure ClearRect(const ARect: TRectF; const AColor: TAlphaColor = 0);
    procedure DrawEllipse(const ARect: TRectF; const AOpacity: Single = 1.0);
    procedure DrawEllipse(const ARect: TRectF; const AOpacity: Single; const ABrush: TStrokeBrush);
    procedure DrawLine(const APt1, APt2: TPointF; const AOpacity: Single = 1.0);
    procedure DrawLine(const APt1, APt2: TPointF; const AOpacity: Single; const ABrush: TStrokeBrush);
    procedure DrawPolygon(const Points: TPolygon; const AOpacity: Single = 1.0);
    procedure DrawRect(const ARect: TRectF; const XRadius, YRadius: Single; const ACorners: TCorners;
      const AOpacity: Single = 1.0; const ACornerType: TCornerType = TCornerType.Round);
    procedure DrawRect(const ARect: TRectF; const XRadius, YRadius: Single; const ACorners: TCorners;
      const AOpacity: Single; const ABrush: TStrokeBrush; const ACornerType: TCornerType = TCornerType.Round);
    procedure EndScene;
    procedure FillEllipse(const ARect: TRectF; const AOpacity: Single = 1.0);
    procedure FillEllipse(const ARect: TRectF; const AOpacity: Single; const ABrush: TBrush);
    procedure FillPolygon(const Points: TPolygon; const AOpacity: Single = 1.0);
    procedure FillRect(const ARect: TRectF; const XRadius, YRadius: Single; const ACorners: TCorners;
      const AOpacity: Single = 1.0; const ACornerType: TCornerType = TCornerType.Round);
    procedure FillRect(const ARect: TRectF; const XRadius, YRadius: Single; const ACorners: TCorners;
      const AOpacity: Single; const ABrush: TBrush; const ACornerType: TCornerType = TCornerType.Round);
    procedure FillText(const ARect: TRectF; const AText: string; const WordWrap: Boolean; const AOpacity: Single;
      const Flags: TFillTextFlags; const ATextAlign: TTextAlign; const AVTextAlign: TTextAlign = TTextAlign.Center);
    procedure Flush;
    procedure MeasureLines(const ALines: TLineMetricInfo; const ARect: TRectF; const AText: string; const WordWrap: Boolean;
      const Flags: TFillTextFlags; const ATextAlign: TTextAlign; const AVTextAlign: TTextAlign = TTextAlign.Center);
    procedure MeasureText(var ARect: TRectF; const AText: string; const WordWrap: Boolean; const Flags: TFillTextFlags;
      const ATextAlign: TTextAlign; const AVTextAlign: TTextAlign = TTextAlign.Center);
    procedure RestoreState(const State: TCanvasSaveState);
    function SaveState: TCanvasSaveState;
    procedure SetSize(const AWidth, AHeight: Integer);
    function TextHeight(const AText: string): Single;
    function TextWidth(const AText: string): Single;

    property BeginSceneCount: Integer read;
    property ClippingChangeCount: Integer read;
    property Fill: TBrush read write;
    property Font: TFont read;
    property Height: Integer read;
    property Offset: TPointF read write;
    property Quality: TCanvasQuality read;
    property SavingStateCount: Integer read;
    property Stroke: TStrokeBrush read;
    property Width: Integer read;
  end;
								

Download and order

Related links