|
|
Donner
C++20 SVG rendering library
|
Parses a CSS <length-percentage> type as defined by https://www.w3.org/TR/css-values-3/#typedef-length-percentage. More...
#include "donner/base/Length.h"
Public Types | |
| enum class | Extent : uint8_t { X , Y , Mixed } |
| Selects which extent of the viewBox to use for percentage and viewBox-relative length conversions, see toPixels(). More... | |
| using | Unit = LengthUnit |
| The unit identifier for the length. | |
Public Member Functions | |
| Length ()=default | |
| Default constructor, initializes to unitless 0. | |
| Length (T value, Unit unit=Unit::None) | |
| Construct a length from a value and unit. | |
| bool | operator== (const Length &other) const |
| Equality operator, using near-equals comparison for the value. | |
| std::partial_ordering | operator<=> (const Length &other) const |
| Spaceship operator, first ordered by the unit if they are not the same, then by the value (with a near-equals comparison). | |
| bool | isAbsoluteSize () const |
| Returns true if the length is an absolute dimension (not a percentage or relative unit). | |
| T | toPixels (const Box< T > &viewBox, const FontMetrics &fontMetrics, Extent extent=Extent::Mixed) const |
| Convert the length to pixels, following the ratios at https://www.w3.org/TR/css-values/#absolute-lengths and https://www.w3.org/TR/css-values/#relative-lengths. | |
Public Attributes | |
| T | value = T(0) |
| The numeric value of the length. | |
| Unit | unit = Unit::None |
| The unit identifier of the length. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Length< T > &length) |
| ostream-output operator for Length. | |
Parses a CSS <length-percentage> type as defined by https://www.w3.org/TR/css-values-3/#typedef-length-percentage.
A length is composed of a number followed by a unit identifier.
Unit identifiers are split into two categories, absolute and relative:
The unit may be omitted for '0', which is unitless.
For a percentage, the number is followed by the '%' character.
Examples:
| T | Value storage type, typically double. |
|
strong |
Selects which extent of the viewBox to use for percentage and viewBox-relative length conversions, see toPixels().
| Enumerator | |
|---|---|
| X | Use X component of viewBox for percentage calculations. |
| Y | Use Y component of viewBox for percentage calculations. |
| Mixed | Use diagonal extent of viewBox. |
|
inlineexplicit |
Construct a length from a value and unit.
| value | The numeric value of the length. |
| unit | The unit identifier of the length. |
|
inline |
Convert the length to pixels, following the ratios at https://www.w3.org/TR/css-values/#absolute-lengths and https://www.w3.org/TR/css-values/#relative-lengths.
| viewBox | ViewBox of the element for computing viewBox-relative conversions. |
| fontMetrics | Font size information for font-relative sizes. |
| extent | Which extent of the viewBox to use for percentage and viewBox-relative length. |
|
friend |