[][src]Module rsvg_internals::length

CSS length values.

Length is the struct librsvg uses to represent CSS lengths. See its documentation for an example of how to construct it.

Length values need to know whether they will be normalized with respect to the width, height, or both dimensions of the current viewport. So, a Length has a type parameter Normalize; the full type is Length<N: Normalize>. We provide Horizontal, Vertical, and Both implementations of Normalize; these let length values know how to normalize themselves with respect to the current viewport.

For example, the implementation of Circle defines this structure with fields for the (center_x, center_y, radius):

This example is not tested
pub struct Circle {
    cx: Length<Horizontal>,
    cy: Length<Vertical>,
    r: Length<Both>,
}

This means that:

The N type parameter of Length<N> is enough to know how to normalize a length value; the normalize method will handle it automatically.

Structs

Both

Allows declaring Length<Both>.

Horizontal

Allows declaring Length<Horizontal>.

Length

A CSS length value.

RsvgLength

A CSS length value.

Vertical

Allows declaring Length<Vertical>.

Enums

LengthUnit

Units for length values.

Constants

CM_PER_INCH
MM_PER_INCH
PICA_PER_INCH
POINTS_PER_INCH

Traits

Normalize

Used for the type parameter of Length<N: Normalize>.

Functions

font_size_from_values
viewport_percentage