Emmanuele Bassi > Clutter > xs/ClutterUnits.xs

Download:
Clutter-1.002.tar.gz

Annotate this POD

CPAN RT

New  2
Open  2
View Bugs
Report a bug
Source  

SYNOPSIS ^

    $units = { type => 'mm', value => 12.0 };
    $pixels = $units->to_pixels();

    $units = Clutter::Units->from_em(3, "Sans 16px");
    print $units->{value};      # "3"
    print $units->to_string();  # "3 em"

    $units = Clutter::Units->from_string("12 pt");
    print $units->{type};       # "pt"
    print $units->to_pixels();

DESCRIPTION ^

Clutter::Units is a data structure holding a logical distance value along with its type, expressed as a value of the Clutter::UnitType enumeration.

It is possible to use Clutter::Units to store a position or a size in units different than pixels, and convert them whenever needed (for instance inside the Clutter::Actor::allocate() virtual function, or inside the Clutter::Actor::get_preferred_width() and Clutter::Actor::get_preferred_height() virtual functions).

A Clutter::Units is represented by a hash reference with two keys, type, holding the unit type; and value, holding the value for the specified type.

The type key can contain one of the following:

px : pixels
em : em
pt : typographic points
mm : millimeters

The value key must contain a double.