Parses the input string and sets the Aspect Ratio properties
Namespace: RSSVGUtils
Delphi |
procedure ParseAspectRatio( const S: String; AspectRatio: TSVGPreserveAspectRatio ); |
Parameters
S
Type: String
[defer][<align>] [<meetOrSlice>]
AspectRatio
Type: TSVGPreserveAspectRatio
In some cases, typically when using the ‘viewBox’ attribute, it is desirable that the graphics stretch to fit non-uniformly to take up the entire viewport. In other cases, it is desirable that uniform scaling be used for the purposes of preserving the aspect ratio of the graphics. Attribute preserveAspectRatio="[defer] <align> [<meetOrSlice>]" , which is available for all elements that establish a new viewport (see elements that establish viewports ), plus the ‘image’ , ‘marker’ , ‘pattern’ and ‘view’ elements, indicates whether or not to force uniform scaling. For elements that establish a new viewport (see elements that establish viewports ), plus the ‘marker’ , ‘pattern’ and ‘view’ elements, ‘preserveAspectRatio’ only applies when a value has been provided for ‘viewBox’ on the same element. For these elements, if attribute ‘viewBox’ is not provided, then ‘preserveAspectRatio’ is ignored. For ‘image’ elements, ‘preserveAspectRatio’ indicates how referenced images should be fitted with respect to the reference rectangle and whether the aspect ratio of the referenced image should be preserved with respect to the current user coordinate system. If the value of ‘preserveAspectRatio’ on an ‘image’ element starts with 'defer' then the value of the ‘preserveAspectRatio’ attribute on the referenced content if present should be used. If the referenced content lacks a value for ‘preserveAspectRatio’ then the ‘preserveAspectRatio’ attribute should be processed as normal (ignoring 'defer' ). For ‘preserveAspectRatio’ on all other elements the 'defer' portion of the attribute is ignored. The <align> parameter indicates whether to force uniform scaling and, if so, the alignment method to use in case the aspect ratio of the ‘viewBox’ doesn't match the aspect ratio of the viewport. The <align> parameter must be one of the following strings: •none - Do not force uniform scaling. Scale the graphic content of the given element non-uniformly if necessary such that the element's bounding box exactly matches the viewport rectangle. •xMinYMin - Force uniform scaling. •xMidYMin - Force uniform scaling. •xMaxYMin - Force uniform scaling. •xMinYMid - Force uniform scaling. •xMidYMid (the default) - Force uniform scaling. •xMaxYMid - Force uniform scaling. •xMinYMax - Force uniform scaling. •xMidYMax - Force uniform scaling. •xMaxYMax - Force uniform scaling. |
The <meetOrSlice> parameter is optional and, if provided, is separated from the <align> value by one or more spaces and then must be one of the following strings:
•meet (the default) - Scale the graphic such that:
• aspect ratio is preserved • the entire ‘viewBox’ is visible within the viewport • the ‘viewBox’ is scaled up as much as possible, while still meeting the other criteria |
In this case, if the aspect ratio of the graphic does not match the viewport, some of the viewport will extend beyond the bounds of the ‘viewBox’ (i.e., the area into which the ‘viewBox’ will draw will be smaller than the viewport).
•slice - Scale the graphic such that:
• aspect ratio is preserved • the entire viewport is covered by the ‘viewBox’ • the ‘viewBox’ is scaled down as much as possible, while still meeting the other criteria |
In this case, if the aspect ratio of the ‘viewBox’ does not match the viewport, some of the ‘viewBox’ will extend beyond the bounds of the viewport (i.e., the area into which the ‘viewBox’ will draw is larger than the viewport).
Reference |