Unit BGRASVG
Description
SVG format implementation
Uses
- BGRAClasses
- SysUtils
- BGRABitmapTypes
- DOM
- BGRAUnits
- BGRASVGShapes
- BGRACanvas2D
- BGRASVGType
- FPimage
Overview
Structures
Name | Description |
---|---|
Class TBGRASVG |
Reading, writing and rendering for an SVG document. |
Class TFPReaderSVG |
Reader for SVG image format |
Class TSVGUnits |
Converter for units within an SVG document or group |
Functions and Procedures
procedure RegisterSvgFormat; |
Types
TCSSUnit = BGRAUnits.TCSSUnit; |
Constants
Description
Functions and Procedures
procedure RegisterSvgFormat; |
This item has no description. |
Types
TCSSUnit = BGRAUnits.TCSSUnit; |
An SVG file has a width and height which describe the viewport size. It is not however really the size of the content. The latter is defined as a rectangle called viewbox. There are thus various ways of drawing an SVG file. If the viewbox is not specified, then it is a rectangle with origin (0,0) and with the same size as the viewport. In this case, a pixel in the viewbox corresponds to a pixel in the viewport. Otherwise, viewbox is scaled to fit the viewport. —— Different DPIs —————– The default DPI of the SVG file is the DPI used to convert between pixel units and other units like centimeters or inches. In general, this should not be used to scale the image, because it can make the SVG measures inconsistent. It should rather be set to the DPI which was used internally and which should be 96 according to CSS specifications. Some programs however use a different DPI so it can be useful to change it according to the source program. The destination DPI that can be specified when drawing can be used to scale the SVG. For example you can prepare your SVG to be at the correct size for 96 DPI display and then draw them on a display for which the apparent DPI is different (this can be set systemwide on Windows and Linux). —— Various ways of scaling ——– There are various functions to draw and also to get the presentation matrix. The latter is a matrix, not including the translation to x and y, that contains all transforms to apply to the viewbox coordinates. The drawing functions are Draw and StretchDraw and to get the presentation matrix the functions are GetPresentationMatrix and GetStretchPresentationMatrix respectively. Drawing in user coordinates, i.e. without taking account of the viewbox or viewport size. One can achieve this by calling the Draw function with an x and y coordinates and a destination unit/DPI. You would do that only if you want to make use of the viewbox offset or if you already have applied all necessary transforms. The corresponding presentation matrix is the identity. Drawing with a specific alignment in user coordinates. This can be done by calling Draw with horizontal and vertical alignment, x and y coordinates to align to, a destination unit/DPI and Scaled set to False. Drawing with a specific alignment, scaled to view port units. This will draw the SVG at its expected size but apply the alignment you want. This is what you would want to do if you want to customize the alignment. One can achieve this as above but by specifying the Scaled parameter to True. Drawing inside a specified rectangle, not preserving the aspect ratio. In this case, you want a certain size and the original size does not matter much. The viewbox of the SVG is stretched to fit the rectangle. One can achieve this by calling StretchDraw with the specified rectangle and the UseSvgAspectRatio to False. Drawing inside a rectangle, using the parameter of the SVG about the aspect ratio. In this case, the SVG may either be stretched as before, scaled to fit the rectangle or scaled to cover it. Also the SVG may be set with a certain horizontal and vertical alignment within the rectangle. One can draw this way by calling StretchDraw with the UseSvgAspectRatio set to True. You would typically use this method to show the SVG as it was intended to look like but in a custom container by suppling WidthAsPixel and HeightAsPixel for the rectangle size. Drawing inside a rectangle, preserving the aspect ratio. In this case, you call StretchDraw with a horizontal and vertical alignment, the rectangle and the Slice parameter. When Slice is set to False, the viewbox will fit the rectangle. If Slice is to True then the viewbox may overflow the rectangle so that it covers the whole surface. Using this function, one can have control over the way the SVG is scaled. Slice is useful for background. Drawing inside a rectangle of the size defined by the SVG. That will draw the SVG as it is supposed to look like. One can do that by calling StretchDraw with a unit parameter. You would typically use pixel units and this will draw to the size WidthAsPixel by HeightAsPixel. |
Constants
cuCentimeter = BGRAUnits.cuCentimeter; |
This item has no description. |
cuCustom = BGRAUnits.cuCustom; |
This item has no description. |
cuFontEmHeight = BGRAUnits.cuFontEmHeight; |
This item has no description. |
cuFontXHeight = BGRAUnits.cuFontXHeight; |
This item has no description. |
cuInch = BGRAUnits.cuInch; |
This item has no description. |
cuMillimeter = BGRAUnits.cuMillimeter; |
This item has no description. |
cuPercent = BGRAUnits.cuPercent; |
This item has no description. |
cuPica = BGRAUnits.cuPica; |
This item has no description. |
cuPixel = BGRAUnits.cuPixel; |
This item has no description. |
cuPoint = BGRAUnits.cuPoint; |
This item has no description. |