Types measurement

SILE measurement type.

Measurements consist of an amount and a unit. Any registered types.unit may be used. Some units are relative and their value may depend on the context where they are evaluated. Others are absolute. Unlike types.length measurements have no stretch or shrink parameters.

Class measurement

measurement:_init(amount[, unit=pt]) Constructor.
measurement:absolute() Convert relative measurements to absolute values and return a measurement.
measurement:tonumber() Convert relative measurements to absolute values and return a number.
measurement:__add(other) Addition meta-method.


Class measurement

measurement:_init(amount[, unit=pt])
Constructor.

Parameters:

  • amount number, length, measurement or string Amount of units or a string with the amount and unit.
  • unit string Name of unit. (default pt)

Returns:

    measurement

Usage:

    SILE.types.measurement(3, "em")
    SILE.types.measurement("2%fw")
    SILE.types.measurement(6)
measurement:absolute()
Convert relative measurements to absolute values and return a measurement. Resolves relative measurements (like em relevant to the current font size) into absolute measurements.

Returns:

    measurement A new measurement in pt with any relative values resolved.

Usage:

    > a = SILE.types.measurement("1.2em")
    > print(a:absolute())
    12pt
measurement:tonumber()
Convert relative measurements to absolute values and return a number. Similar to measurement:absolute but returns a number instead of a new measurement type.

Returns:

    number A number (corresponding to pts) for the amount with any relative values resolved.
measurement:__add(other)
Addition meta-method. Assuming matching relative units or absolute units, allows two measurements to be combined into one.

Parameters:

Returns:

    measuremnet A new measurement of the same unit type as self with the value of other added.

Usage:

    > a = SILE.types.measurement(6, "em")
    > b = SILE.types.measurement("2em")
    > c = a + b
    > print(c)
    8em
generated by LDoc 1.5.0 Last updated 1980-01-01 00:00:00