inkex.units module#

Convert to and from various units and find the closest matching unit.

inkex.units.parse_unit(value, default_unit='px', default_value=None)[source]#

Takes a value such as 55.32px and returns (55.32, ‘px’) Returns default (None) if no match can be found

inkex.units.are_near_relative(point_a, point_b, eps=0.01)[source]#

Return true if the points are near to eps

inkex.units.discover_unit(value, viewbox, default='px')[source]#

Attempt to detect the unit being used based on the viewbox

inkex.units.convert_unit(value, to_unit, default='px')[source]#

Returns userunits given a string representation of units in another system

Parameters
  • value – <length> string

  • to_unit – unit to convert to

  • default

    if value contains no unit, what unit should be assumed.

    New in version 1.1.

inkex.units.render_unit(value, unit)[source]#

Checks and then renders a number with its unit