Length value type and object

Length type reperesents length (distance) values such as mm, cm, px, in, pt, etc.

Length values are constructed by following

Constructor functions

em
( v: int | float ) : length, these functions constructs length values of correspondent type.
ex
( v: int | float ) : length
pr
( v: int | float ) : length
flex
( v: int | float ) : length
px
( v: int | float ) : length
in
( v: int | float ) : length
cm
( v: int | float ) : length
mm
( v: int | float ) : length
pt
( v: int | float ) : length
pc
( v: int | float ) : length
dip
( v: int | float ) : length

Constants

N/A

Properties

units read-only, symbol, one of:
  • #em - em font units;
  • #ex - ex font units;
  • #pr - percents '%';
  • #flex - flex units '%%' (in h-smile core);
  • #px - pixels, usually device dependent;
  • #in - inches;
  • #cm - centimeters;
  • #mm - millimeters;
  • #pt - typographical point (1/72 of inch)
  • #pc - typographical pica (1/12 of point)
  • #dip - device independent pixels ( 1/96 of inch )

Methods

parse

( text: string [, defval: undefined ) : length | defval

static method (method of the class), parses text for the length value. In case of parsing failure returns value defined by defval.

make
( v: int | float, units: symbol ) : length

static function, constructs length of correspondent value and the unit symbol (above).

toString

( ) : string

Returns string representation of the value, e.g. "12.5pt",  "1px", etc.

toInteger

( ) : int

Converts the length to integer.

toFloat

( ) : float

Converts the length to float.