Skip to content

TSVG2LinkedImage

No description yet.

Framework Unit Inherits from
VCL BVE.SVG2ImageList.VCL TSVG2CustomLinkedImage → TSVG2BaseControl → TGraphicControl
FMX BVE.SVG2ImageList.FMX TSVG2CustomLinkedImage → TSVG2BaseControl → TControl
FPC BVE.SVG2ImageList.FPC TSVG2CustomLinkedImage → TSVG2BaseControl → TGraphicControl

Properties

Published, so they can be set in the Object Inspector.

AnimationTimer

property AnimationTimer: TSVG2AnimationTimer;

Reference to an TSVG2AnimationTimer

AspectRatioAlign

property AspectRatioAlign: TSVGAspectRatioAlign;

Default arXMidYMid

If AutoViewbox is TRUE, this will set the align of the preserveAspectRatio property of the svg element

AspectRatioMeetOrSlice

property AspectRatioMeetOrSlice: TSVGAspectRatioMeetOrSlice;

Default arMeet

If AutoViewbox is TRUE, this will set the meetOrSlice of the preserveAspectRatio property of the svg element

AutoViewbox

property AutoViewbox: boolean;

Default True

This will insert a viewbox on the root element if none is present in the original svg. The content will be centered in the middle and fit into the bounds of the control, respecting aspect ratio.

Bitmap

property Bitmap: TBitmap;

read-only

The internal bitmap buffer.

BufferQuality

property BufferQuality: TSVGBufferQuality;

VCL, FPC only · Default bqHighQuality

The buffer quality is passed on to the render context implementation.

Clipping

property Clipping: boolean;

Default False

If true, the bitmap buffer bounds are clipped to the canvas to prevent memory overflow on extreme scaling

ImageIndex

// VCL
property ImageIndex: integer;

// FMX
property ImageIndex: TImageIndex;

The index in the connected image list that specifies the SVG to use.

Images

// VCL
property Images: TSVG2BaseImageList;

// FMX
property Images: TCustomImageList;

The TSVG2ImageList that contains the SVG.

Padding

// VCL
property Padding: TPadding;

// FMX
property Padding: TBounds;

Adds space between the SVG image and the edge of the control.

RenderOptions

property RenderOptions: TSVGRenderOptions;

Default [sroClippath, sroFilters]

sroClippath: Clippaths are rendered; sroFilters: Filters are rendered; sroEvents: SVG events are enabled.

RootID

property RootID: string;

The id of the svg element where rendering will start. If left empty the parser will start with the outer most SVG element.

Run-time properties

Public, so available from code only.

AnimationTime

property AnimationTime: Cardinal;

Get or set the animation time in ms

ContentBounds

property ContentBounds: TRectF;

read-only

The calculated bounds of the SVG.

ElementIndex

property ElementIndex: TStrings;

read-only

List of Element id's.

FilterBufferMaxPixels

property FilterBufferMaxPixels: Integer;

Default SVGFilterBufferMaxPixelsDefault

The number of pixels a buffer rendered for a filter may take. A filter that needs more is rendered at a lower resolution and scaled up, so zooming deep into a filtered drawing stays bounded in time and memory instead of failing. Zero means no limit.

HasAnimations

property HasAnimations: Boolean;

read-only

True if the currently selected document in the root has Smil or CSS animations.

HideDesignRect

property HideDesignRect: Boolean;

Hide the rectangle that is shown in the designer

Iri

property Iri: TSVGIri;

Resource identifier constructed from filename and root id

MousePan

property MousePan: Boolean;

Default False

Dragging with the left button moves the view. Off by default.

MouseZoom

property MouseZoom: Boolean;

FMX only · Default False

The wheel zooms, about the middle of the control. Off by default.

Note

FMX reports the wheel without saying where the pointer was, so this zooms about the middle. Call ZoomByWheel from the form's own handler to zoom about the pointer instead.

NeedsParse

property NeedsParse: boolean;

Will force a parse of the SVG content on the next paint.

NeedsRepaint

property NeedsRepaint: boolean;

Will force the SVG to be re-rendered on the next paint.

ParseErrorMessage

property ParseErrorMessage: string;

read-only

The message of the last parse error while painting, or empty when the drawing was parsed.

RenderContextType

property RenderContextType: TSVGRenderContextType;

read-only

Returns the render context type used.

Scale

property Scale: TSVGFloat;

VCL, FPC only

Scale of the control for Form scaling support

SVGBindings

property SVGBindings: TSVGBindingCollection;

Values bound to elements of the document.

Note

Each binding names elements with a selector - by id, tag, class or attribute - and writes its value to them, as an attribute or as their text content. Assigning a binding's Value repaints the control.

SVGParser

property SVGParser: TSVGSaxParser;

read-only

Pointer to the parser object of the control.

SVGRoot

property SVGRoot: ISVGRoot;

The root of the rendering tree.

SVGRotateAngle

property SVGRotateAngle: TSVGFloat;

VCL, FPC only

No description yet.

SVGRotateCenterX

property SVGRotateCenterX: TSVGFloat;

VCL, FPC only

No description yet.

SVGRotateCenterY

property SVGRotateCenterY: TSVGFloat;

VCL, FPC only

No description yet.

SVGScaleX

property SVGScaleX: TSVGFloat;

VCL, FPC only

No description yet.

SVGScaleY

property SVGScaleY: TSVGFloat;

VCL, FPC only

No description yet.

SVGTranslateX

property SVGTranslateX: TSVGFloat;

VCL, FPC only

No description yet.

SVGTranslateY

property SVGTranslateY: TSVGFloat;

VCL, FPC only

No description yet.

Transform

property Transform: TSVGMatrix;

VCL, FPC only

Transformation matrix

WheelZoomStep

property WheelZoomStep: TSVGFloat;

How much one notch of the wheel zooms by. 1.1 is a tenth in or out.

ZoomFactor

property ZoomFactor: TSVGFloat;

The zoom, as a factor on the size the drawing is shown at when it fits the control. Writing it zooms about the middle of the control.

Note

The same thing as SVGScaleX and SVGScaleY, which it keeps equal to each other. Kept between ZoomMin and ZoomMax.

ZoomMax

property ZoomMax: TSVGFloat;

No description yet.

ZoomMin

property ZoomMin: TSVGFloat;

The smallest and largest the zoom is allowed to get.

Events

OnAfterParse

property OnAfterParse: TNotifyEvent;

Occurs after the svg is parsed and the size of the svg content is calculated.

OnLoadEmbeddedResource

property OnLoadEmbeddedResource: TSVGLoadEmbeddedResourceEvent;

Occurs when an embedded resource is loaded

OnLoadExternalResource

property OnLoadExternalResource: TSVGLoadExternalResourceEvent;

Occurs when an external resource is loaded

OnLog

property OnLog: TSVGLogEvent;

Occurs when there is a log message

OnPaint

property OnPaint: TNotifyEvent;

Occurs after the painting

OnParseError

property OnParseError: TSVGParseErrorEvent;

Occurs when the drawing could not be parsed while the component painted, for a missing file or one that is not well-formed XML. The component shows the message in its own area either way. Calling ParseSVG raises the exception instead.

OnSVGEvent

property OnSVGEvent: TSVGEvent;

Occurs on an SVG event

OnViewChanged

property OnViewChanged: TNotifyEvent;

Occurs after the zoom or the pan changes, however it changed.

Methods

Assign

procedure Assign(Source: TPersistent);

Copies the values from the object provided by aSource.

CalcSize

procedure CalcSize;

Set the size of the control to the intrinsic size of the SVG.

ClientToSVG

function ClientToSVG(const aPt: TSVGPoint): TSVGPoint;

Turns a point on the control into a point in the drawing, in the user units of its outer svg element, undoing the zoom, the pan and the fit to the control.

Note

The fit is known once the control has painted; before that the point comes back as if the drawing were shown at its own size.

ElementBounds

function ElementBounds(const aID: string): TSVGRect;

The bounds of the element with id aID, in the coordinates of the drawing (the user units of its outer svg element), whatever the zoom, pan and fit to the control. Undefined when there is no such element or it is not rendered.

Note

An axis-aligned box that includes the stroke; for a rotated element it is the box around it, and for an element drawn in several places (a symbol placed by use) the box around all of them. Works before the first paint and after changes in code: the drawing is laid out first when needed.

ObjectAtPt

// VCL
function ObjectAtPt(
  const aPt: TSVGPoint;
  const aIfHitTest: boolean = True): ISVGObject;

// FMX
function ObjectAtPt(
  const aPt: TPointF;
  const aIfHitTest: boolean = True): ISVGObject;

Finds the element of type TSVGObject at the supplied user coordinates. If no element is found the function returns nil. If aIfHitTest is set to TRUE, then only TSVGObject elements that have the "Hittest" property set to TRUE are checked. It follows pointer-events, visibility and clip paths, as a click would; sroEvents is not needed for it, only for the SVG events. A shape drawn through a use element is returned as the outermost use element, so that each placement of a symbol can be told apart.

PanBy

procedure PanBy(const aDX, aDY: TSVGFloat);

Moves the view by aDX and aDY, in pixels of the control.

ParseSVG

procedure ParseSVG;

Parses the drawing from SVGDoc, SVG or FileName now. Assigning those properties does not parse; the component otherwise parses when it is next painted, and then shows a parse error as text in its own area. Called directly, it raises the exception (EDOMParseError on Delphi) for a missing or malformed file, so call it inside try..except for drawings from outside the application. OnAfterParse follows a successful parse.

Repaint

procedure Repaint;

Forces a re-render of the SVG and a repaint of the control.

ResetView

procedure ResetView;

Puts the zoom back to 1 and the pan and rotation back to nothing, so the drawing is shown the way it is when first loaded.

SVGReadCompressed

procedure SVGReadCompressed(Stream: TStream);

No description yet.

SVGToClient

function SVGToClient(const aPt: TSVGPoint): TSVGPoint;

Turns a point in the drawing into a point on the control, the other way round from ClientToSVG.

SVGWriteCompressed

procedure SVGWriteCompressed(Stream: TStream);

No description yet.

ZoomAt

procedure ZoomAt(const aPt: TSVGPoint; const aFactor: TSVGFloat);

Multiplies the zoom by aFactor while holding aPt, a point on the control, where it is. This is what zooming on the pointer means.

ZoomByWheel

procedure ZoomByWheel(const aWheelDelta: Integer; const aPt: TSVGPoint);

One turn of the mouse wheel: zooms about aPt by WheelZoomStep for every notch in aWheelDelta.

Note

A control without a window of its own is never sent the wheel message, so this is called from the form's OnMouseWheel. The windowed control does it for itself when MouseZoom is on.

ZoomToElement

function ZoomToElement(
  const aID: string;
  const aMargin: TSVGFloat = 0): Boolean;

Zooms and pans so that the element with id aID fills the control. aMargin adds that fraction of the element's size on each side, so 0.1 leaves a tenth free around it. Returns False, and leaves the view alone, when there is no such element or it is not rendered.

ZoomToFit

procedure ZoomToFit;

Zooms and pans so that everything the drawing paints is in view.

ZoomToRect

procedure ZoomToRect(const aRect: TSVGRect);

Zooms and pans so that aRect, in the coordinates of the drawing, fills the control.

Inherited from the framework

VCL, published from TGraphicControl: Align, Anchors, AutoSize, Color, Constraints, DragCursor, DragKind, DragMode, Enabled, OnClick, OnContextPopup, OnDblClick, OnDragDrop, OnDragOver, OnEndDock, OnEndDrag, OnGesture, OnMouseActivate, OnMouseDown, OnMouseEnter, OnMouseLeave, OnMouseMove, OnMouseUp, OnStartDock, OnStartDrag, ParentShowHint, PopupMenu, ShowHint, Touch, Visible

FMX, published from TControl: Align, Anchors, ClipChildren, ClipParent, Cursor, DragMode, Enabled, EnableDragHighlight, HitTest, Locked, Margins, OnClick, OnDblClick, OnDragDrop, OnDragEnd, OnDragEnter, OnDragLeave, OnDragOver, OnMouseDown, OnMouseEnter, OnMouseLeave, OnMouseMove, OnMouseUp, OnMouseWheel, OnPainting, OnResize, Opacity, PopupMenu, Position, RotationAngle, RotationCenter, Scale, Size, Visible

FPC, published from TGraphicControl: Align, Anchors, AutoSize, Color, Constraints, DragCursor, DragKind, DragMode, Enabled, OnClick, OnContextPopup, OnDblClick, OnDragDrop, OnDragOver, OnEndDock, OnEndDrag, OnMouseDown, OnMouseEnter, OnMouseLeave, OnMouseMove, OnMouseUp, OnStartDock, OnStartDrag, ParentShowHint, PopupMenu, ShowHint, Visible

Framework methods this component overrides, which behave as the framework documents them: AutoAdjustLayout, Create, Destroy, Paint, SetBounds