Class TBGRASVG
Unit
Declaration
type TBGRASVG = class(TSVGCustomElement)
Description
Reading, writing and rendering for an SVG document.
Example of reading and displaying SVG images:
uses ..., BGRABitmapTypes, BGRASVG; procedure DrawSVGImages(ctx: TBGRACanvas2D); var svg: TBGRASVG; begin svg := TBGRASVG.Create; svg.LoadFromFile('Amsterdammertje-icoon.svg'); svg.StretchDraw(ctx, taCenter,tlCenter, 0,0,ctx.Width/3,ctx.Height); svg.LoadFromFile('BespectacledMaleUser.svg'); svg.StretchDraw(ctx, ctx.Width/3,0,ctx.Width*2/3,ctx.Height/2); ctx.save; ctx.beginPath; ctx.rect(ctx.Width/3,ctx.Height/2,ctx.Width*2/3,ctx.Height/2); ctx.clip; svg.LoadFromFile('Blue_gyroelongated_pentagonal_pyramid.svg'); svg.Draw(ctx, taCenter,tlCenter, ctx.Width*2/3,ctx.Height*3/4); ctx.restore; svg.Free; ctx.beginPath; ctx.lineWidth:= 1; ctx.strokeStyle(BGRABlack); ctx.moveTo(ctx.Width/3,0); ctx.lineTo(ctx.Width/3,ctx.Height); ctx.moveTo(ctx.Width/3,ctx.Height/2); ctx.lineTo(ctx.Width,ctx.Height/2); ctx.stroke; end;
Hierarchy
- TObject
- TSVGCustomElement
- TBGRASVG
Overview
Fields
FContent: TSVGContent; |
|
FDataLink: TSVGDataLink; |
|
FDefaultDpi: single; |
|
FXml: TXMLDocument; |
Methods
constructor Create(AFilenameUTF8: string); overload; |
|
constructor Create(AWidth,AHeight: single; AUnit: TCSSUnit); overload; |
|
constructor Create; overload; |
|
constructor Create(AStream: TStream); overload; |
|
constructor CreateFromString(AUTF8String: string); |
|
destructor Destroy; override; |
|
function Duplicate: TBGRASVG; |
|
function FindElementById(AID: string; AClass: TSVGFactory): TSVGElement; overload; |
|
function FindElementById(AID: string): TSVGElement; overload; |
|
function GetPresentationMatrix(AHorizAlign: TAlignment; AVertAlign: TTextLayout; AUnit: TCSSUnit; AScale: boolean): TAffineMatrix; |
|
function GetStretchPresentationMatrix(AUnit: TCSSUnit): TAffineMatrix; overload; |
|
function GetStretchPresentationMatrix(w,h: single; useSvgAspectRatio: boolean = false): TAffineMatrix; overload; |
|
function GetStretchPresentationMatrix(AHorizAlign: TAlignment; AVertAlign: TTextLayout; w,h: single; ASlice: boolean = false): TAffineMatrix; overload; |
|
function GetStretchRectF(x,y,w,h: single): TRectF; overload; |
|
function GetStretchRectF(AHorizAlign: TAlignment; AVertAlign: TTextLayout; x,y,w,h: single; ASlice: boolean = false): TRectF; overload; |
|
function GetViewBoxAlignment(AHorizAlign: TAlignment; AVertAlign: TTextLayout; AUnit: TCSSUnit): TPointF; |
|
function GetViewBoxScale: TPointF; |
|
procedure ConvertToUnit(AUnit: TCSSUnit); override; |
|
procedure CropToViewBox(AScale: single = 1); |
|
procedure Draw(ACanvas2d: TBGRACanvas2D; AHorizAlign: TAlignment; AVertAlign: TTextLayout; x,y: single; destDpi: single; AScale: boolean = true); overload; |
|
procedure Draw(ACanvas2d: TBGRACanvas2D; AHorizAlign: TAlignment; AVertAlign: TTextLayout; x,y: single; destDpi: TPointF; AScale: boolean = true); overload; |
|
procedure Draw(ACanvas2d: TBGRACanvas2D; AHorizAlign: TAlignment; AVertAlign: TTextLayout; x,y: single; AUnit: TCSSUnit = cuPixel; AScale: boolean = true); overload; |
|
procedure Draw(ACanvas2d: TBGRACanvas2D; x,y: single; AUnit: TCSSUnit = cuPixel); overload; |
|
procedure Draw(ACanvas2d: TBGRACanvas2D; x,y: single; destDpi: single); overload; |
|
procedure Draw(ACanvas2d: TBGRACanvas2D; x,y: single; destDpi: TPointF); overload; |
|
procedure IterateElements(ACallback: TIterateElementCallback; AData: pointer; ARecursive: boolean); override; |
|
procedure LoadFromFile(AFilenameUTF8: string); |
|
procedure LoadFromResource(AFilename: string); |
|
procedure LoadFromStream(AStream: TStream; AURI: UnicodeString = 'stream:'); |
|
procedure SaveToFile(AFilenameUTF8: string); |
|
procedure SaveToStream(AStream: TStream); |
|
procedure StretchDraw(ACanvas2d: TBGRACanvas2D; r: TRectF; useSvgAspectRatio: boolean = false); overload; |
|
procedure StretchDraw(ACanvas2d: TBGRACanvas2D; x,y,w,h: single; useSvgAspectRatio: boolean = false); overload; |
|
procedure StretchDraw(ACanvas2d: TBGRACanvas2D; x, y: single; AUnit: TCSSUnit); overload; |
|
procedure StretchDraw(ACanvas2d: TBGRACanvas2D; AHorizAlign: TAlignment; AVertAlign: TTextLayout; r: TRectF; ASlice: boolean = false); overload; |
|
procedure StretchDraw(ACanvas2d: TBGRACanvas2D; AHorizAlign: TAlignment; AVertAlign: TTextLayout; x,y,w,h: single; ASlice: boolean = false); overload; |
|
procedure Init(ACreateEmpty: boolean); |
|
procedure SetAttribute(AName: string; AValue: string); override; |
|
procedure UnitsRecompute(Sender: TObject); |
Properties
property AsUTF8String: utf8string read GetUTF8String write SetUTF8String; |
|
property Attribute[AName: string]: string read GetAttribute write SetAttribute; |
|
property AttributeDef[AName: string; ADefault: string]: string read GetAttribute; |
|
property Color: TBGRAPixel read GetColor write SetColor; |
|
property ComputedHeight: TFloatWithCSSUnit read GetComputedHeight; |
|
property ComputedWidth: TFloatWithCSSUnit read GetComputedWidth; |
|
property ContainerHeight: TFloatWithCSSUnit read GetContainerHeight write SetContainerHeight; |
|
property ContainerHeightAsPixel: single read GetContainerHeightAsPixel write SetContainerHeightAsPixel; |
|
property ContainerWidth: TFloatWithCSSUnit read GetContainerWidth write SetContainerWidth; |
|
property ContainerWidthAsPixel: single read GetContainerWidthAsPixel write SetContainerWidthAsPixel; |
|
property Content: TSVGContent read FContent; |
|
property DataLink: TSVGDataLink read FDataLink; |
|
property DefaultDpi: single read FDefaultDpi write SetDefaultDpi; |
|
property FontSize: TFloatWithCSSUnit read GetFontSize write SetFontSize; |
|
property Height: TFloatWithCSSUnit read GetHeight write SetHeight; |
|
property HeightAsCm: single read GetHeightAsCm write SetHeightAsCm; |
|
property HeightAsInch: single read GetHeightAsInch write SetHeightAsInch; |
|
property HeightAsPixel: single read GetHeightAsPixel write SetHeightAsPixel; |
|
property Layer[AIndex: integer]: TSVGGroup read GetLayer; |
|
property LayerCount: integer read GetLayerCount; |
|
property preserveAspectRatio: TSVGPreserveAspectRatio read GetPreserveAspectRatio write SetPreserveAspectRatio; |
|
property Units: TSVGUnits read GetUnits; |
|
property ViewBox: TSVGViewBox read GetViewBox write SetViewBox; |
|
property ViewBoxInUnit[AUnit: TCSSUnit]: TSVGViewBox read GetViewBox; |
|
property ViewMinInUnit[AUnit: TCSSUnit]: TPointF read GetViewMin; |
|
property ViewSizeInUnit[AUnit: TCSSUnit]: TPointF read GetViewSize; |
|
property VisualHeight: TFloatWithCSSUnit read GetVisualHeight; |
|
property VisualHeightAsPixel: single read GetVisualHeightAsPixel; |
|
property VisualWidth: TFloatWithCSSUnit read GetVisualWidth; |
|
property VisualWidthAsPixel: single read GetVisualWidthAsPixel; |
|
property Width: TFloatWithCSSUnit read GetWidth write SetWidth; |
|
property WidthAsCm: single read GetWidthAsCm write SetWidthAsCm; |
|
property WidthAsInch: single read GetWidthAsInch write SetWidthAsInch; |
|
property WidthAsPixel: single read GetWidthAsPixel write SetWidthAsPixel; |
|
property Zoomable: boolean read GetZoomable write SetZoomable; |
Description
Fields
FContent: TSVGContent; |
|
This item has no description. |
FDataLink: TSVGDataLink; |
|
This item has no description. |
FDefaultDpi: single; |
|
This item has no description. |
FXml: TXMLDocument; |
|
This item has no description. |
Methods
constructor Create(AFilenameUTF8: string); overload; |
|
This item has no description. |
constructor Create(AWidth,AHeight: single; AUnit: TCSSUnit); overload; |
|
This item has no description. |
constructor Create; overload; |
|
This item has no description. |
constructor Create(AStream: TStream); overload; |
|
This item has no description. |
constructor CreateFromString(AUTF8String: string); |
|
This item has no description. |
destructor Destroy; override; |
|
This item has no description. |
function Duplicate: TBGRASVG; |
|
This item has no description. |
function FindElementById(AID: string; AClass: TSVGFactory): TSVGElement; overload; |
|
This item has no description. |
function FindElementById(AID: string): TSVGElement; overload; |
|
This item has no description. |
function GetPresentationMatrix(AHorizAlign: TAlignment; AVertAlign: TTextLayout; AUnit: TCSSUnit; AScale: boolean): TAffineMatrix; |
|
This item has no description. |
function GetStretchPresentationMatrix(AUnit: TCSSUnit): TAffineMatrix; overload; |
|
This item has no description. |
function GetStretchPresentationMatrix(w,h: single; useSvgAspectRatio: boolean = false): TAffineMatrix; overload; |
|
This item has no description. |
function GetStretchPresentationMatrix(AHorizAlign: TAlignment; AVertAlign: TTextLayout; w,h: single; ASlice: boolean = false): TAffineMatrix; overload; |
|
This item has no description. |
function GetStretchRectF(x,y,w,h: single): TRectF; overload; |
|
This item has no description. |
function GetStretchRectF(AHorizAlign: TAlignment; AVertAlign: TTextLayout; x,y,w,h: single; ASlice: boolean = false): TRectF; overload; |
|
This item has no description. |
function GetViewBoxAlignment(AHorizAlign: TAlignment; AVertAlign: TTextLayout; AUnit: TCSSUnit): TPointF; |
|
This item has no description. |
function GetViewBoxScale: TPointF; |
|
This item has no description. |
procedure ConvertToUnit(AUnit: TCSSUnit); override; |
|
This item has no description. |
procedure CropToViewBox(AScale: single = 1); |
|
This item has no description. |
procedure Draw(ACanvas2d: TBGRACanvas2D; AHorizAlign: TAlignment; AVertAlign: TTextLayout; x,y: single; destDpi: single; AScale: boolean = true); overload; |
|
This item has no description. |
procedure Draw(ACanvas2d: TBGRACanvas2D; AHorizAlign: TAlignment; AVertAlign: TTextLayout; x,y: single; destDpi: TPointF; AScale: boolean = true); overload; |
|
This item has no description. |
procedure Draw(ACanvas2d: TBGRACanvas2D; AHorizAlign: TAlignment; AVertAlign: TTextLayout; x,y: single; AUnit: TCSSUnit = cuPixel; AScale: boolean = true); overload; |
|
This item has no description. |
procedure Draw(ACanvas2d: TBGRACanvas2D; x,y: single; AUnit: TCSSUnit = cuPixel); overload; |
|
This item has no description. |
procedure Draw(ACanvas2d: TBGRACanvas2D; x,y: single; destDpi: single); overload; |
|
This item has no description. |
procedure Draw(ACanvas2d: TBGRACanvas2D; x,y: single; destDpi: TPointF); overload; |
|
This item has no description. |
procedure IterateElements(ACallback: TIterateElementCallback; AData: pointer; ARecursive: boolean); override; |
|
This item has no description. |
procedure LoadFromFile(AFilenameUTF8: string); |
|
This item has no description. |
procedure LoadFromResource(AFilename: string); |
|
This item has no description. |
procedure LoadFromStream(AStream: TStream; AURI: UnicodeString = 'stream:'); |
|
This item has no description. |
procedure SaveToFile(AFilenameUTF8: string); |
|
This item has no description. |
procedure SaveToStream(AStream: TStream); |
|
This item has no description. |
procedure StretchDraw(ACanvas2d: TBGRACanvas2D; r: TRectF; useSvgAspectRatio: boolean = false); overload; |
|
This item has no description. |
procedure StretchDraw(ACanvas2d: TBGRACanvas2D; x,y,w,h: single; useSvgAspectRatio: boolean = false); overload; |
|
This item has no description. |
procedure StretchDraw(ACanvas2d: TBGRACanvas2D; x, y: single; AUnit: TCSSUnit); overload; |
|
This item has no description. |
procedure StretchDraw(ACanvas2d: TBGRACanvas2D; AHorizAlign: TAlignment; AVertAlign: TTextLayout; r: TRectF; ASlice: boolean = false); overload; |
|
This item has no description. |
procedure StretchDraw(ACanvas2d: TBGRACanvas2D; AHorizAlign: TAlignment; AVertAlign: TTextLayout; x,y,w,h: single; ASlice: boolean = false); overload; |
|
This item has no description. |
procedure Init(ACreateEmpty: boolean); |
|
This item has no description. |
procedure SetAttribute(AName: string; AValue: string); override; |
|
This item has no description. |
procedure UnitsRecompute(Sender: TObject); |
|
This item has no description. |
Properties
property AsUTF8String: utf8string read GetUTF8String write SetUTF8String; |
|
except Width, Height, ContainerWidth, ContainerHeight |
property Attribute[AName: string]: string read GetAttribute write SetAttribute; |
|
This item has no description. |
property AttributeDef[AName: string; ADefault: string]: string read GetAttribute; |
|
This item has no description. |
property Color: TBGRAPixel read GetColor write SetColor; |
|
This item has no description. |
property ComputedHeight: TFloatWithCSSUnit read GetComputedHeight; |
|
This item has no description. |
property ComputedWidth: TFloatWithCSSUnit read GetComputedWidth; |
|
This item has no description. |
property ContainerHeight: TFloatWithCSSUnit read GetContainerHeight write SetContainerHeight; |
|
This item has no description. |
property ContainerHeightAsPixel: single read GetContainerHeightAsPixel write SetContainerHeightAsPixel; |
|
This item has no description. |
property ContainerWidth: TFloatWithCSSUnit read GetContainerWidth write SetContainerWidth; |
|
This item has no description. |
property ContainerWidthAsPixel: single read GetContainerWidthAsPixel write SetContainerWidthAsPixel; |
|
This item has no description. |
property Content: TSVGContent read FContent; |
|
this is not saved in the SVG file |
property DataLink: TSVGDataLink read FDataLink; |
|
This item has no description. |
property DefaultDpi: single read FDefaultDpi write SetDefaultDpi; |
|
This item has no description. |
property FontSize: TFloatWithCSSUnit read GetFontSize write SetFontSize; |
|
This item has no description. |
property Height: TFloatWithCSSUnit read GetHeight write SetHeight; |
|
This item has no description. |
property HeightAsCm: single read GetHeightAsCm write SetHeightAsCm; |
|
This item has no description. |
property HeightAsInch: single read GetHeightAsInch write SetHeightAsInch; |
|
This item has no description. |
property HeightAsPixel: single read GetHeightAsPixel write SetHeightAsPixel; |
|
This item has no description. |
property Layer[AIndex: integer]: TSVGGroup read GetLayer; |
|
This item has no description. |
property LayerCount: integer read GetLayerCount; |
|
This item has no description. |
property preserveAspectRatio: TSVGPreserveAspectRatio read GetPreserveAspectRatio write SetPreserveAspectRatio; |
|
(for test or internal info) |
property Units: TSVGUnits read GetUnits; |
|
This item has no description. |
property ViewBox: TSVGViewBox read GetViewBox write SetViewBox; |
|
This item has no description. |
property ViewBoxInUnit[AUnit: TCSSUnit]: TSVGViewBox read GetViewBox; |
|
This item has no description. |
property ViewMinInUnit[AUnit: TCSSUnit]: TPointF read GetViewMin; |
|
This item has no description. |
property ViewSizeInUnit[AUnit: TCSSUnit]: TPointF read GetViewSize; |
|
This item has no description. |
property VisualHeight: TFloatWithCSSUnit read GetVisualHeight; |
|
This item has no description. |
property VisualHeightAsPixel: single read GetVisualHeightAsPixel; |
|
This item has no description. |
property VisualWidth: TFloatWithCSSUnit read GetVisualWidth; |
|
This item has no description. |
property VisualWidthAsPixel: single read GetVisualWidthAsPixel; |
|
This item has no description. |
property Width: TFloatWithCSSUnit read GetWidth write SetWidth; |
|
This item has no description. |
property WidthAsCm: single read GetWidthAsCm write SetWidthAsCm; |
|
This item has no description. |
property WidthAsInch: single read GetWidthAsInch write SetWidthAsInch; |
|
This item has no description. |
property WidthAsPixel: single read GetWidthAsPixel write SetWidthAsPixel; |
|
This item has no description. |
property Zoomable: boolean read GetZoomable write SetZoomable; |
|
This item has no description. |