|
|
Donner
C++20 SVG rendering library
|
Handles SVG's preserveAspectRatio attribute. More...
#include "donner/svg/core/PreserveAspectRatio.h"
Public Types | |
| enum class | Align : uint8_t { None , XMinYMin , XMidYMin , XMaxYMin , XMinYMid , XMidYMid , XMaxYMid , XMinYMax , XMidYMax , XMaxYMax } |
| Alignment options for preserveAspectRatio. More... | |
| enum class | MeetOrSlice : uint8_t { Meet , Slice } |
| Scaling methods for preserveAspectRatio. More... | |
Public Member Functions | |
| double | alignMultiplierX () const |
| Calculates the horizontal alignment factor. | |
| double | alignMultiplierY () const |
| Calculates the vertical alignment factor. | |
| Transformd | elementContentFromViewBoxTransform (const Boxd &size, std::optional< Boxd > viewBox) const |
| Computes the transformation in destinationFromSource notation that maps coordinates from the viewBox coordinate system (source) to the element's content coordinate system (destination). | |
| bool | operator== (const PreserveAspectRatio &other) const |
| Equality operator. | |
Static Public Member Functions | |
| static PreserveAspectRatio | Default () |
| Create a default PreserveAspectRatio from the SVG2 spec, which is XMidYMid meet. | |
| static PreserveAspectRatio | None () |
| Creates a PreserveAspectRatio with 'none' alignment. | |
Public Attributes | |
| Align | align = Align::XMidYMid |
| Default: XMidYMid per SVG spec. | |
| MeetOrSlice | meetOrSlice = MeetOrSlice::Meet |
| Default: Meet per SVG spec. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const PreserveAspectRatio &value) |
| Outputs a string representation of PreserveAspectRatio to a stream. | |
Handles SVG's preserveAspectRatio attribute.
|
strong |
Alignment options for preserveAspectRatio.
|
strong |
|
inline |
Calculates the horizontal alignment factor.
|
inline |
Calculates the vertical alignment factor.
|
inlinestatic |
Create a default PreserveAspectRatio from the SVG2 spec, which is XMidYMid meet.
| Transformd donner::svg::PreserveAspectRatio::elementContentFromViewBoxTransform | ( | const Boxd & | size, |
| std::optional< Boxd > | viewBox ) const |
Computes the transformation in destinationFromSource notation that maps coordinates from the viewBox coordinate system (source) to the element's content coordinate system (destination).
The size parameter represents the destination rectangle for the element's content, while the optional viewBox parameter defines the source coordinate system. If no viewBox is provided, the transformation is a simple translation to the topâleft of size.
| size | The destination rectangle for the element's content. |
| viewBox | The source viewBox rectangle, if any. |
|
inlinestatic |
Creates a PreserveAspectRatio with 'none' alignment.
Useful for scenarios where aspect ratio should be ignored.
|
friend |
Outputs a string representation of PreserveAspectRatio to a stream.
Format: "PreserveAspectRatio {<align>, <meetOrSlice>}" Example: "PreserveAspectRatio {Align::XMidYMid, MeetOrSlice::Meet}"