---
name: "Clutter::Units"
section: "3pm"
platform: "linux"
package: "libclutter-perl"
version: "1.002-1"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/Clutter::Units"
---

# Clutter::Units(3pm)

A logical distance unit

## NAME

Clutter::Units - A logical distance unit

## 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.

## HIERARCHY

```
  Glib::Boxed
  +----Clutter::Units
```

## METHODS

### units = Clutter::Units-\>from\_em ($em, $font\_name=undef)

- •

  `$em` (double)

- •

  `$font_name` (string)

### units = Clutter::Units-\>from\_mm ($mm)

- •

  `$mm` (double)

### units = Clutter::Units-\>from\_pixels ($pixels)

- •

  `$pixels` (integer)

### units = Clutter::Units-\>from\_pt ($pt)

- •

  `$pt` (double)

### units = Clutter::Units-\>from\_string ($string)

- •

  `$string` (string)

### double = $units-\>to\_pixels

### string = $units-\>to\_string

## ENUMS AND FLAGS

### enum Clutter::UnitType

- •

  'pixel' / 'CLUTTER\_UNIT\_PIXEL'

- •

  'em' / 'CLUTTER\_UNIT\_EM'

- •

  'mm' / 'CLUTTER\_UNIT\_MM'

- •

  'point' / 'CLUTTER\_UNIT\_POINT'

## SEE ALSO

Clutter, Glib::Boxed

## COPYRIGHT

Copyright (C) 2006, 2007, 2008  OpenedHand Ltd

Copyright (C) 2009  Intel Corporation

This module is free software; you can redistribute it and/or modify it under the terms of either:

- •

  the GNU Lesser General Public Library version 2.1; or

- •

  the Artistic License, version 2.0.

See Clutter for the full copyright notice.
