Class TSVGContent

Unit

Declaration

type TSVGContent = class(TObject)

Description

Content for an SVG element.

It can be used to browse or add elements.

Example creating an SVG file:

content

uses BGRABitmapTypes, BGRASVG, BGRAUnits;
var svg: TBGRASVG;
begin
  //it is recommended to initialise the SVG with size and unit
  //otherwise, the size is kind of undefined

  svg := TBGRASVG.Create(10,6,cuCentimeter);
  svg.Content.AppendPath('M1,1 L9,1 9,5 1,5 z', cuCentimeter).fillColor := CSSGreen;
  svg.Content.AppendRect(2,2,6,2, cuCentimeter).fillColor:= BGRA(255,255,0,192);
  with svg.Content.AppendRect(0,0,svg.Units.ConvertWidth(1,cuCentimeter,cuPixel),
  svg.Units.ConvertHeight(1,cuCentimeter,cuPixel), cuPixel) do
  begin
    fillColor := CSSBlue;
    fillOpacity:= 0.2;
  end;
  svg.Content.AppendRoundRect(3,3,4,1, 0.3,0.3, cuCentimeter).fillColor := CSSOrange;
  with svg.Content.AppendLine(30,140,250,30, cuPoint) do
  begin
    strokeColor := BGRABlack;
    strokeOpacity:= 0.8;
  end;
  svg.Content.AppendLine(svg.ViewBox.min,svg.ViewBox.min+svg.ViewBox.size).strokeColor := CSSRed;
  with svg.Content.AppendCircle(5,3,2.8,cuCentimeter) do
  begin
    strokeColor := CSSRed;
    strokeWidth := FloatWithCSSUnit(2,cuPoint);
    fillNone;
  end;

  //SVG can be saved in a file that can be viewed in
  //a web browser or in InkScape for example
  svg.SaveToFile('content.svg');
  svg.Free;
end.

Hierarchy

Overview

Fields

Protected FDataLink: TSVGDataLink;
Protected FDoc: TDOMDocument;
Protected FDomElem: TDOMElement;
Protected FElements: TFPList;
Protected FUnits: TCSSUnitConverter;

Methods

Public constructor Create(AElement: TDOMElement; AUnits: TCSSUnitConverter; ADataLink: TSVGDataLink);
Public destructor Destroy; override;
Public function AppendCircle(c: TPointF; r: single; AUnit: TCSSUnit = cuCustom): TSVGCircle; overload;
Public function AppendCircle(cx,cy,r: single; AUnit: TCSSUnit = cuCustom): TSVGCircle; overload;
Public function AppendDefine: TSVGDefine;
Public function AppendDOMText(AText: string): TDOMText;
Public function AppendElement(ASVGType: TSVGFactory): TSVGElement; overload;
Public function AppendEllipse(c,r: TPointF; AUnit: TCSSUnit = cuCustom): TSVGEllipse; overload;
Public function AppendEllipse(cx,cy,rx,ry: single; AUnit: TCSSUnit = cuCustom): TSVGEllipse; overload;
Public function AppendGroup: TSVGGroup;
Public function AppendImage(origin,size: TPointF; ABitmapStream: TStream; AMimeType: string; AUnit: TCSSUnit = cuCustom): TSVGImage; overload;
Public function AppendImage(x,y,width,height: single; ABitmap: TBGRACustomBitmap; ABitmapOwned: boolean; AUnit: TCSSUnit = cuCustom): TSVGImage; overload;
Public function AppendImage(origin,size: TPointF; ABitmap: TBGRACustomBitmap; ABitmapOwned: boolean; AUnit: TCSSUnit = cuCustom): TSVGImage; overload;
Public function AppendImage(x,y,width,height: single; ABitmapStream: TStream; AMimeType: string; AUnit: TCSSUnit = cuCustom): TSVGImage; overload;
Public function AppendLine(x1,y1,x2,y2: single; AUnit: TCSSUnit = cuCustom): TSVGLine; overload;
Public function AppendLine(p1,p2: TPointF; AUnit: TCSSUnit = cuCustom): TSVGLine; overload;
Public function AppendLinearGradient(x1,y1,x2,y2: single; AIsPercent: boolean): TSVGLinearGradient; overload;
Public function AppendLinearGradient(x1,y1,x2,y2: single; AUnit: TCSSUnit): TSVGLinearGradient; overload;
Public function AppendPath(path: TBGRAPath; AUnit: TCSSUnit = cuCustom): TSVGPath; overload;
Public function AppendPath(data: string; AUnit: TCSSUnit = cuCustom): TSVGPath; overload;
Public function AppendPolygon(const points: array of TPointF; AUnit: TCSSUnit = cuCustom): TSVGPolypoints; overload;
Public function AppendPolygon(const points: array of single; AUnit: TCSSUnit = cuCustom): TSVGPolypoints; overload;
Public function AppendRadialGradient(cx,cy,r,fx,fy,fr: single; AIsPercent: boolean): TSVGRadialGradient; overload;
Public function AppendRadialGradient(cx,cy,r,fx,fy,fr: single; AUnit: TCSSUnit): TSVGRadialGradient; overload;
Public function AppendRect(origin,size: TPointF; AUnit: TCSSUnit = cuCustom): TSVGRectangle; overload;
Public function AppendRect(x,y,width,height: single; AUnit: TCSSUnit = cuCustom): TSVGRectangle; overload;
Public function AppendRoundRect(x,y,width,height,rx,ry: single; AUnit: TCSSUnit = cuCustom): TSVGRectangle; overload;
Public function AppendRoundRect(origin,size,radius: TPointF; AUnit: TCSSUnit = cuCustom): TSVGRectangle; overload;
Public function AppendStop(AColor: TBGRAPixel; AOffset: single; AIsPercent: boolean): TSVGStopGradient;
Public function AppendText(x,y: single; AText: string; AUnit: TCSSUnit = cuCustom): TSVGText; overload;
Public function AppendText(origin: TPointF; AText: string; AUnit: TCSSUnit = cuCustom): TSVGText; overload;
Public function AppendTextSpan(AText: string): TSVGTSpan;
Public function IndexOfElement(AElement: TObject): integer;
Protected function ExtractElementAt(AIndex: integer): TObject;
Protected function GetDOMNode(AElement: TObject): TDOMNode;
Protected function GetElement(AIndex: integer): TSVGElement;
Protected function GetElementCount: integer;
Protected function GetElementDOMNode(AIndex: integer): TDOMNode;
Protected function GetElementObject(AIndex: integer): TObject;
Protected function GetIsSVGElement(AIndex: integer): boolean;
Protected function GetUnits: TCSSUnitConverter;
Protected function TryCreateElementFromNode(ANode: TDOMNode): TObject; virtual;
Public procedure BringElement(AElement: TObject; AFromContent: TSVGContent); overload;
Public procedure Clear;
Public procedure ConvertToUnit(AUnit: TCSSUnit);
Public procedure CopyElement(AElement: TObject);
Public procedure CopyPathTo(ACanvas2d: TBGRACanvas2D; x,y: single; AUnit: TCSSUnit); overload;
Public procedure CopyPathTo(ACanvas2d: TBGRACanvas2D; AUnit: TCSSUnit); overload;
Public procedure Draw(ACanvas2d: TBGRACanvas2D; AUnit: TCSSUnit); overload;
Public procedure Draw(ACanvas2d: TBGRACanvas2D; x,y: single; AUnit: TCSSUnit); overload;
Public procedure IterateElements(ACallback: TIterateElementCallback; AData: pointer; ARecursive: boolean);
Public procedure Recompute;
Public procedure RemoveElement(AElement: TObject);
Protected procedure AppendElement(AElement: TObject); overload;
Protected procedure InsertElementBefore(AElement: TSVGElement; ASuccessor: TSVGElement);

Properties

Public property Element[AIndex: integer]: TSVGElement read GetElement;
Public property ElementCount: integer read GetElementCount;
Public property ElementDOMNode[AIndex: integer]: TDOMNode read GetElementDOMNode;
Public property ElementObject[AIndex: integer]: TObject read GetElementObject;
Public property IsSVGElement[AIndex: integer]: boolean read GetIsSVGElement;
Public property Units: TCSSUnitConverter read GetUnits;

Description

Fields

Protected FDataLink: TSVGDataLink;

This item has no description.

Protected FDoc: TDOMDocument;

This item has no description.

Protected FDomElem: TDOMElement;

This item has no description.

Protected FElements: TFPList;

This item has no description.

Protected FUnits: TCSSUnitConverter;

This item has no description.

Methods

Public constructor Create(AElement: TDOMElement; AUnits: TCSSUnitConverter; ADataLink: TSVGDataLink);

This item has no description.

Public destructor Destroy; override;

This item has no description.

Public function AppendCircle(c: TPointF; r: single; AUnit: TCSSUnit = cuCustom): TSVGCircle; overload;

This item has no description.

Public function AppendCircle(cx,cy,r: single; AUnit: TCSSUnit = cuCustom): TSVGCircle; overload;

This item has no description.

Public function AppendDefine: TSVGDefine;

This item has no description.

Public function AppendDOMText(AText: string): TDOMText;

This item has no description.

Public function AppendElement(ASVGType: TSVGFactory): TSVGElement; overload;

This item has no description.

Public function AppendEllipse(c,r: TPointF; AUnit: TCSSUnit = cuCustom): TSVGEllipse; overload;

This item has no description.

Public function AppendEllipse(cx,cy,rx,ry: single; AUnit: TCSSUnit = cuCustom): TSVGEllipse; overload;

This item has no description.

Public function AppendGroup: TSVGGroup;

This item has no description.

Public function AppendImage(origin,size: TPointF; ABitmapStream: TStream; AMimeType: string; AUnit: TCSSUnit = cuCustom): TSVGImage; overload;

This item has no description.

Public function AppendImage(x,y,width,height: single; ABitmap: TBGRACustomBitmap; ABitmapOwned: boolean; AUnit: TCSSUnit = cuCustom): TSVGImage; overload;

This item has no description.

Public function AppendImage(origin,size: TPointF; ABitmap: TBGRACustomBitmap; ABitmapOwned: boolean; AUnit: TCSSUnit = cuCustom): TSVGImage; overload;

This item has no description.

Public function AppendImage(x,y,width,height: single; ABitmapStream: TStream; AMimeType: string; AUnit: TCSSUnit = cuCustom): TSVGImage; overload;

This item has no description.

Public function AppendLine(x1,y1,x2,y2: single; AUnit: TCSSUnit = cuCustom): TSVGLine; overload;

This item has no description.

Public function AppendLine(p1,p2: TPointF; AUnit: TCSSUnit = cuCustom): TSVGLine; overload;

This item has no description.

Public function AppendLinearGradient(x1,y1,x2,y2: single; AIsPercent: boolean): TSVGLinearGradient; overload;

This item has no description.

Public function AppendLinearGradient(x1,y1,x2,y2: single; AUnit: TCSSUnit): TSVGLinearGradient; overload;

This item has no description.

Public function AppendPath(path: TBGRAPath; AUnit: TCSSUnit = cuCustom): TSVGPath; overload;

This item has no description.

Public function AppendPath(data: string; AUnit: TCSSUnit = cuCustom): TSVGPath; overload;

This item has no description.

Public function AppendPolygon(const points: array of TPointF; AUnit: TCSSUnit = cuCustom): TSVGPolypoints; overload;

This item has no description.

Public function AppendPolygon(const points: array of single; AUnit: TCSSUnit = cuCustom): TSVGPolypoints; overload;

This item has no description.

Public function AppendRadialGradient(cx,cy,r,fx,fy,fr: single; AIsPercent: boolean): TSVGRadialGradient; overload;

This item has no description.

Public function AppendRadialGradient(cx,cy,r,fx,fy,fr: single; AUnit: TCSSUnit): TSVGRadialGradient; overload;

This item has no description.

Public function AppendRect(origin,size: TPointF; AUnit: TCSSUnit = cuCustom): TSVGRectangle; overload;

This item has no description.

Public function AppendRect(x,y,width,height: single; AUnit: TCSSUnit = cuCustom): TSVGRectangle; overload;

This item has no description.

Public function AppendRoundRect(x,y,width,height,rx,ry: single; AUnit: TCSSUnit = cuCustom): TSVGRectangle; overload;

This item has no description.

Public function AppendRoundRect(origin,size,radius: TPointF; AUnit: TCSSUnit = cuCustom): TSVGRectangle; overload;

This item has no description.

Public function AppendStop(AColor: TBGRAPixel; AOffset: single; AIsPercent: boolean): TSVGStopGradient;

This item has no description.

Public function AppendText(x,y: single; AText: string; AUnit: TCSSUnit = cuCustom): TSVGText; overload;

This item has no description.

Public function AppendText(origin: TPointF; AText: string; AUnit: TCSSUnit = cuCustom): TSVGText; overload;

This item has no description.

Public function AppendTextSpan(AText: string): TSVGTSpan;

This item has no description.

Public function IndexOfElement(AElement: TObject): integer;

This item has no description.

Protected function ExtractElementAt(AIndex: integer): TObject;

This item has no description.

Protected function GetDOMNode(AElement: TObject): TDOMNode;

This item has no description.

Protected function GetElement(AIndex: integer): TSVGElement;

This item has no description.

Protected function GetElementCount: integer;

This item has no description.

Protected function GetElementDOMNode(AIndex: integer): TDOMNode;

This item has no description.

Protected function GetElementObject(AIndex: integer): TObject;

This item has no description.

Protected function GetIsSVGElement(AIndex: integer): boolean;

This item has no description.

Protected function GetUnits: TCSSUnitConverter;

This item has no description.

Protected function TryCreateElementFromNode(ANode: TDOMNode): TObject; virtual;

This item has no description.

Public procedure BringElement(AElement: TObject; AFromContent: TSVGContent); overload;

This item has no description.

Public procedure Clear;

This item has no description.

Public procedure ConvertToUnit(AUnit: TCSSUnit);

This item has no description.

Public procedure CopyElement(AElement: TObject);

This item has no description.

Public procedure CopyPathTo(ACanvas2d: TBGRACanvas2D; x,y: single; AUnit: TCSSUnit); overload;

This item has no description.

Public procedure CopyPathTo(ACanvas2d: TBGRACanvas2D; AUnit: TCSSUnit); overload;

This item has no description.

Public procedure Draw(ACanvas2d: TBGRACanvas2D; AUnit: TCSSUnit); overload;

This item has no description.

Public procedure Draw(ACanvas2d: TBGRACanvas2D; x,y: single; AUnit: TCSSUnit); overload;

This item has no description.

Public procedure IterateElements(ACallback: TIterateElementCallback; AData: pointer; ARecursive: boolean);

This item has no description.

Public procedure Recompute;

This item has no description.

Public procedure RemoveElement(AElement: TObject);

This item has no description.

Protected procedure AppendElement(AElement: TObject); overload;

This item has no description.

Protected procedure InsertElementBefore(AElement: TSVGElement; ASuccessor: TSVGElement);

This item has no description.

Properties

Public property Element[AIndex: integer]: TSVGElement read GetElement;

This item has no description.

Public property ElementCount: integer read GetElementCount;

This item has no description.

Public property ElementDOMNode[AIndex: integer]: TDOMNode read GetElementDOMNode;

This item has no description.

Public property ElementObject[AIndex: integer]: TObject read GetElementObject;

This item has no description.

Public property IsSVGElement[AIndex: integer]: boolean read GetIsSVGElement;

This item has no description.

Public property Units: TCSSUnitConverter read GetUnits;

This item has no description.