Expand description
CSS length values.
CssLength is the struct librsvg uses to represent CSS lengths.
See its documentation for examples of how to construct it.
CssLength values need to know whether they will be normalized with respect to the width,
height, or both dimensions of the current viewport. CssLength values can be signed or
unsigned. So, a CssLength has two type parameters, Normalize and Validate;
the full type is CssLength<N: Normalize, V: Validate>. We provide Horizontal,
Vertical, and Both implementations of Normalize; these let length values know
how to normalize themselves with respect to the current viewport. We also provide
Signed and Unsigned implementations of Validate.
For ease of use, we define two type aliases Length and ULength corresponding to
signed and unsigned.
For example, the implementation of Circle defines this
structure with fields for the (center_x, center_y, radius):
pub struct Circle {
cx: Length<Horizontal>,
cy: Length<Vertical>,
r: ULength<Both>,
}This means that:
-
cxandcydefine the center of the circle, they can be positive or negative, and they will be normalized with respect to the current viewport’s width and height, respectively. If the SVG document specified<circle cx="50%" cy="30%">, the values would be normalized to be at 50% of the the viewport’s width, and 30% of the viewport’s height. -
ris non-negative and needs to be resolved against the normalized diagonal of the current viewport.
The N type parameter of CssLength<N, I> is enough to know how to normalize a length
value; the CssLength::to_user method will handle it automatically.
Structs§
- Both
- Allows declaring
CssLength<Both>. - CssLength
- A CSS length value.
- Horizontal
- Allows declaring
CssLength<Horizontal>. - Normalize
Params - Parameters to normalize
Lengthvalues to user-space distances. - Normalize
Values - Parameters for length normalization extracted from
ComputedValues. - Rsvg
Length - A CSS length value.
- Signed
- Used to implement
CssLength<N, Signed>. - Unsigned
- Used to implement
CssLength<N, Unsigned>. - Vertical
- Allows declaring
CssLength<Vertical>.
Enums§
- Length
OrAuto - Length
Unit - Units for length values.
Constants§
Traits§
- Normalize
- Used for the
Ntype parameter ofCssLength<N: Normalize, V: Validate>. - Validate
- Used for the
Vtype parameter ofCssLength<N: Normalize, V: Validate>.