units
New in version 0.9.0.
Contents
- class ooodev.units.UnitCM(value)[source]
Unit in
cm
units.Supports
UnitT
protocol.See also
New in version 0.9.4.
- Parameters:
value (float) –
- classmethod from_cm(value)[source]
Get instance from
cm
value.- Parameters:
value (float) –
cm
value.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in
(inch) value.- Parameters:
value (int) –
in
value.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in
(inch) value.- Parameters:
value (int) –
`/10th in
value.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in
(inch) value.- Parameters:
value (int) –
1/100th in
value.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in
(inch) value.- Parameters:
value (int) –
1/1,000th in
value.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mm
value.- Parameters:
value (int) –
mm
value.- Return type:
- classmethod from_mm10(value)[source]
Get instance from
1/10th mm
value.- Parameters:
value (int) –
1/10th mm
value.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mm
value.- Parameters:
value (int) –
1/100th mm
value.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt
(points) value.- Parameters:
value (float) –
pt
value.- Return type:
- classmethod from_px(value)[source]
Get instance from
px
(pixel) value.- Parameters:
value (float) –
px
value.- Return type:
- get_value_cm()[source]
Gets instance value converted to
cm
units.- Returns:
Value in
cm
units.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to
mm
units.- Returns:
Value in
mm
units.- Return type:
int
- get_value_mm100()[source]
Gets instance value converted to
1/100th mm
units.- Returns:
Value in
1/100th mm
units.- Return type:
int
- get_value_pt()[source]
Gets instance value converted to
pt
(points) units.- Returns:
Value in
pt
units.- Return type:
int
- get_value_px()[source]
Gets instance value in
px
(pixel) units.- Returns:
Value in
px
units.- Return type:
int
- value: float
Float value.
- class ooodev.units.UnitConvert[source]
- static asserting_gcd(m, n)[source]
Find the greatest common divisor of the two integers
- Parameters:
m (int) – The first integer to find the GCD for
n (int) – The second integer to find the GCD for
- Raises:
AssertionError – If GCD result equals
0
.- Returns:
A value, representing the greatest common divisor (GCD) for two integers
- Return type:
int
- classmethod convert(num: int | float, frm: ooodev.units.unit_convert.UnitLength, to: ooodev.units.unit_convert.UnitLength) float [source]
- classmethod convert(num: int | float, frm: int, to: int) float
- classmethod convert(num, frm, to)
Converts a number from one unit to another unit.
- Parameters:
num (N) – Number to convert such as a
float
orint
.frm (int | Length) – Current number kind.
to (int | Length) – Kind to convert to.
- Returns:
Converted number
- Return type:
float
Note
If
Length
is not used thenmul_div()
is called directly.
- classmethod convert_mm100_mm(num)[source]
Converts
mm
to1/100th mm
- Parameters:
num (N) – Number to convert
- Returns:
Converted number
- Return type:
float
- classmethod convert_mm100_pt(num)[source]
Converts
1/100th mm
to points- Parameters:
num (N) – Number to convert
- Returns:
Converted number
- Return type:
float
- classmethod convert_mm_mm100(num)[source]
Converts
1/100th mm
tomm
- Parameters:
num (N) – Number to convert
- Returns:
Converted number
- Return type:
float
- classmethod convert_pt_mm100(num)[source]
Converts points to
1/100th mm
- Parameters:
num (N) – Number to convert
- Returns:
Converted number
- Return type:
float
- classmethod convert_twip_mm100(num)[source]
Converts twips to
1/100th mm
- Parameters:
num (N) – Number to convert
- Returns:
Converted number
- Return type:
float
- static make_unsigned(num)[source]
Gets unsigned number
- Parameters:
num (N) – Number
- Raises:
AssertionError – If
num
is a negative number.- Returns:
Value of
num
if positive number.- Return type:
N
- class ooodev.units.UnitInch(value)[source]
Unit in
inch
units.Supports
UnitT
protocol.See also
- Parameters:
value (float) –
- classmethod from_cm(value)[source]
Get instance from
cm
value.- Parameters:
value (float) –
cm
value.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in
(inch) value.- Parameters:
value (int) –
1/10th in
value.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in
(inch) value.- Parameters:
value (int) –
1/100th in
value.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in
(inch) value.- Parameters:
value (int) –
1/1,000th in
value.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mm
value.- Parameters:
value (float) –
mm
value.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mm
value.- Parameters:
value (int) –
1/100th mm
value.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt
(points) value.- Parameters:
value (float) –
pt
value.- Return type:
- classmethod from_px(value)[source]
Get instance from
px
(pixel) value.- Parameters:
value (float) –
px
value.- Return type:
- get_value_cm()[source]
Gets instance value converted to
cm
units.- Returns:
Value in
cm
units.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to Size in
mm
units.- Returns:
Value in
mm
units.- Return type:
int
- get_value_mm100()[source]
Gets instance value converted to Size in
1/100th mm
units.- Returns:
Value in
1/100th mm
units.- Return type:
int
- get_value_pt()[source]
Gets instance value converted to Size in
pt
(points) units.- Returns:
Value in
pt
units.- Return type:
int
- get_value_px()[source]
Gets instance value in
px
(pixel) units.- Returns:
Value in
px
units.- Return type:
int
- value: float
Float value.
- class ooodev.units.UnitInch10(value)[source]
Unit in
1/10th in
units.Supports
UnitT
protocol.See also
- Parameters:
value (float) –
- classmethod from_cm(value)[source]
Get instance from
cm
value.- Parameters:
value (float) –
cm
value.- Return type:
- classmethod from_in(value)[source]
Get instance from
in
(inch) value.- Parameters:
value (float) –
in
value.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in
(inch) value.- Parameters:
value (int) –
1/10th in
value.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in
(inch) value.- Parameters:
value (int) –
1/100th in
value.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in
(inch) value.- Parameters:
value (int) –
1/1,000th in
value.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mm
value.- Parameters:
value (int) –
1/100th mm
value.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt
(points) value.- Parameters:
value (float) –
pt
value.- Return type:
- classmethod from_px(value)[source]
Get instance from
px
(pixel) value.- Parameters:
value (float) –
px
value.- Return type:
- get_value_cm()[source]
Gets instance value converted to
cm
units.- Returns:
Value in
cm
units.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to
mm
units.- Returns:
Value in
mm
units.- Return type:
int
- get_value_mm100()[source]
Gets instance value converted to
1/100th mm
units.- Returns:
Value in
1/100th mm
units.- Return type:
int
- get_value_pt()[source]
Gets instance value converted to Size in
pt
(points) units.- Returns:
Value in
pt
units.- Return type:
int
- get_value_px()[source]
Gets instance value in
px
(pixel) units.- Returns:
Value in
px
units.- Return type:
int
- value: float
Float value.
- class ooodev.units.UnitInch100(value)[source]
Unit in
1/100th in
units.Supports
UnitT
protocol.See also
- Parameters:
value (float) –
- classmethod from_cm(value)[source]
Get instance from
cm
value.- Parameters:
value (float) –
cm
value.- Return type:
- classmethod from_in(value)[source]
Get instance from
in
(inch) value.- Parameters:
value (float) –
in
value.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in
(inch) value.- Parameters:
value (int) –
1/10th in
value.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/10th in
(inch) value.- Parameters:
value (int) –
1/10th in
value.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in
(inch) value.- Parameters:
value (int) –
1/1,000th in
value.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mm
value.- Parameters:
value (int) –
1/100th mm
value.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt
(points) value.- Parameters:
value (float) –
pt
value.- Return type:
- classmethod from_px(value)[source]
Get instance from
px
(pixel) value.- Parameters:
value (float) –
px
value.- Return type:
- get_value_cm()[source]
Gets instance value converted to
cm
units.- Returns:
Value in
cm
units.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to Size in
mm
units.- Returns:
Value in
mm
units.- Return type:
int
- get_value_mm100()[source]
Gets instance value converted to Size in
1/100th mm
units.- Returns:
Value in
1/100th mm
units.- Return type:
int
- get_value_pt()[source]
Gets instance value converted to Size in
pt
(points) units.- Returns:
Value in
pt
units.- Return type:
int
- get_value_px()[source]
Gets instance value in
px
(pixel) units.- Returns:
Value in
px
units.- Return type:
int
- value: float
Float value.
- class ooodev.units.UnitInch1000(value)[source]
Represents
1/1,000th in
units.Supports
UnitT
protocol.See also
- Parameters:
value (int) –
- classmethod from_cm(value)[source]
Get instance from
cm
value.- Parameters:
value (int) –
cm
value.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in
(inch) value.- Parameters:
value (int) –
in
value.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in
(inch) value.- Parameters:
value (int) –
`/10th in
value.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in
(inch) value.- Parameters:
value (int) –
1/100th in
value.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in
(inch) value.- Parameters:
value (int) –
1/1,000th in
value.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mm
value.- Parameters:
value (int) –
mm
value.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt
(points) value.- Parameters:
value (int) –
pt
value.- Return type:
- classmethod from_px(value)[source]
Get instance from
px
(pixel) value.- Parameters:
value (float) –
px
value.- Return type:
- get_value_cm()[source]
Gets instance value converted to
cm
units.- Returns:
Value in
cm
units.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to
mm
units.- Returns:
Value in
mm
units.- Return type:
int
- get_value_mm100()[source]
Gets instance value in
1/100th mm
units.- Returns:
Value in
1/100th mm
units.- Return type:
int
- get_value_pt()[source]
Gets instance value converted to
pt
(point) units.- Returns:
Value in
pt
units.- Return type:
int
- get_value_px()[source]
Gets instance value in
px
(pixel) units.- Returns:
Value in
px
units.- Return type:
int
- value: int
Int value.
- class ooodev.units.UnitLength(value)[source]
An enumeration.
- CH = 18
210
twip (14 px
)- Type:
char unit
- CM = 3
centimeter
- COUNT = 20
- EMU = 6
1/360000 cm
,1/914400 in
- Type:
English Metric Unit
- FT = 14
foot
- IN = 13
inch
- IN10 = 12
1/10 in
- IN100 = 11
1/100 in
- IN1000 = 10
1/1000 in
- INVALID = -1
invalid
- KM = 5
kilometer
- LINE = 19
312
twip- Type:
line unit
- M = 4
meter
- MASTER = 16
1/576 in
- Type:
PPT Master Unit
- MI = 15
mile
- MM = 2
millimeter
- MM10 = 1
1/10 mm
- MM100 = 0
1/100th mm
- PC = 9
1/6 in
- Type:
Pica
- PX = 17
15
twip (96 ppi
)- Type:
pixel unit
- TWIP = 7
1/20 pt
- Type:
Twentieth of a point aka
dxa
- class ooodev.units.UnitMM(value)[source]
Unit in
mm
units.Supports
UnitT
protocol.See also
- Parameters:
value (float) –
- classmethod from_cm(value)[source]
Get instance from
cm
value.- Parameters:
value (int) –
cm
value.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in
(inch) value.- Parameters:
value (int) –
in
value.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in
(inch) value.- Parameters:
value (int) –
1/10th in
value.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in
(inch) value.- Parameters:
value (int) –
1/100th in
value.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in
(inch) value.- Parameters:
value (int) –
1/1,000th in
value.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mm
value.- Parameters:
value (int) –
mm
value.- Return type:
- classmethod from_mm10(value)[source]
Get instance from
1/10th mm
value.- Parameters:
value (int) –
1/10th mm
value.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mm
value.- Parameters:
value (int) –
1/100th mm
value.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt
(points) value.- Parameters:
value (float) –
pt
value.- Return type:
- classmethod from_px(value)[source]
Get instance from
px
(pixel) value.- Parameters:
value (float) –
px
value.- Return type:
- get_value_cm()[source]
Gets instance value converted to
cm
units.- Returns:
Value in
cm
units.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to Size in
mm
units.- Returns:
Value in
mm
units.- Return type:
int
- get_value_mm100()[source]
Gets instance value converted to Size in
1/100th mm
units.- Returns:
Value in
1/100th mm
units.- Return type:
int
- get_value_pt()[source]
Gets instance value converted to Size in
pt
(points) units.- Returns:
Value in
pt
units.- Return type:
int
- get_value_px()[source]
Gets instance value in
px
(pixel) units.- Returns:
Value in
px
units.- Return type:
int
- value: float
Float value.
- class ooodev.units.UnitMM10(value)[source]
Unit in
1/10th mm
units.Supports
UnitT
protocol.See also
- Parameters:
value (float) –
- classmethod from_cm(value)[source]
Get instance from
cm
value.- Parameters:
value (int) –
cm
value.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in
(inch) value.- Parameters:
value (int) –
in
value.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in
(inch) value.- Parameters:
value (int) –
`/10th in
value.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in
(inch) value.- Parameters:
value (int) –
1/100th in
value.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in
(inch) value.- Parameters:
value (int) –
1/1,000th in
value.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mm
value.- Parameters:
value (int) –
mm
value.- Return type:
- classmethod from_mm10(value)[source]
Get instance from
1/10th mm
value.- Parameters:
value (int) –
1/10th mm
value.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mm
value.- Parameters:
value (int) –
1/100th mm
value.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt
(points) value.- Parameters:
value (float) –
pt
value.- Return type:
- classmethod from_px(value)[source]
Get instance from
px
(pixel) value.- Parameters:
value (float) –
px
value.- Return type:
- get_value_cm()[source]
Gets instance value converted to
cm
units.- Returns:
Value in
cm
units.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to
mm
units.- Returns:
Value in
mm
units.- Return type:
int
- get_value_mm100()[source]
Gets instance value converted to
1/100th mm
units.- Returns:
Value in
1/100th mm
units.- Return type:
int
- get_value_pt()[source]
Gets instance value converted to
pt
(points) units.- Returns:
Value in
pt
units.- Return type:
int
- get_value_px()[source]
Gets instance value in
px
(pixel) units.- Returns:
Value in
px
units.- Return type:
int
- value: float
Float value.
- class ooodev.units.UnitMM100(value)[source]
Represents
1/100th mm
units.Supports
UnitT
protocol.See also
- Parameters:
value (int) –
- classmethod from_cm(value)[source]
Get instance from
cm
value.- Parameters:
value (int) –
cm
value.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in
(inch) value.- Parameters:
value (int) –
in
value.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in
(inch) value.- Parameters:
value (int) –
`/10th in
value.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in
(inch) value.- Parameters:
value (int) –
1/100th in
value.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in
(inch) value.- Parameters:
value (int) –
1/1,000th in
value.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mm
value.- Parameters:
value (int) –
mm
value.- Return type:
- classmethod from_mm10(value)[source]
Get instance from
1/10th mm
value.- Parameters:
value (int) –
1/10th mm
value.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mm
value.- Parameters:
value (int) –
1/100th mm
value.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt
(points) value.- Parameters:
value (int) –
pt
value.- Return type:
- classmethod from_px(value)[source]
Get instance from
px
(pixel) value.- Parameters:
value (float) –
px
value.- Return type:
- get_value_cm()[source]
Gets instance value converted to
cm
units.- Returns:
Value in
cm
units.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to
mm
units.- Returns:
Value in
mm
units.- Return type:
int
- get_value_mm100()[source]
Gets instance value in
1/100th mm
units.- Returns:
Value in
1/100th mm
units.- Return type:
int
- get_value_pt()[source]
Gets instance value converted to
pt
(point) units.- Returns:
Value in
pt
units.- Return type:
int
- get_value_px()[source]
Gets instance value in
px
(pixel) units.- Returns:
Value in
px
units.- Return type:
int
- value: int
Int value.
- class ooodev.units.UnitPT(value)[source]
Represents a
PT
(points) value.Supports
UnitT
protocol.See also
- Parameters:
value (float) –
- classmethod from_cm(value)[source]
Get instance from
cm
value.- Parameters:
value (int) –
cm
value.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in
(inch) value.- Parameters:
value (int) –
in
value.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in
(inch) value.- Parameters:
value (int) –
1/10th in
value.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in
(inch) value.- Parameters:
value (int) –
1/100th in
value.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in
(inch) value.- Parameters:
value (int) –
1/1,000th in
value.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mm
value.- Parameters:
value (int) –
mm
value.- Return type:
- classmethod from_mm10(value)[source]
Get instance from
1/10th mm
value.- Parameters:
value (int) –
1/10th mm
value.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mm
value.- Parameters:
value (int) –
1/100th mm
value.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt
(points) value.- Parameters:
value (float) –
pt
value.- Return type:
- classmethod from_px(value)[source]
Get instance from
px
(pixel) value.- Parameters:
value (float) –
px
value.- Return type:
- get_value_cm()[source]
Gets instance value converted to
cm
units.- Returns:
Value in
cm
units.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to
mm
units.- Returns:
Value in
mm
units.- Return type:
int
- get_value_mm100()[source]
Gets instance value converted to
1/100th mm
units.- Returns:
Value in
1/100th mm
units.- Return type:
int
- get_value_pt()[source]
Gets instance value in
pt
(point) units.- Returns:
Value in
pt
units.- Return type:
int
- get_value_px()[source]
Gets instance value in
px
(pixel) units.- Returns:
Value in
px
units.- Return type:
int
- value: float
Float value.
- class ooodev.units.UnitPX(value)[source]
Represents a
PX
(pixel) value.Supports
UnitT
protocol.See also
- Parameters:
value (float) –
- classmethod from_cm(value)[source]
Get instance from
cm
value.- Parameters:
value (int) –
cm
value.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in
(inch) value.- Parameters:
value (int) –
in
value.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in
(inch) value.- Parameters:
value (int) –
1/10th in
value.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in
(inch) value.- Parameters:
value (int) –
1/100th in
value.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in
(inch) value.- Parameters:
value (int) –
1/1,000th in
value.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mm
value.- Parameters:
value (int) –
mm
value.- Return type:
- classmethod from_mm10(value)[source]
Get instance from
1/10th mm
value.- Parameters:
value (int) –
1/10th mm
value.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mm
value.- Parameters:
value (int) –
1/100th mm
value.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt
(points) value.- Parameters:
value (float) –
pt
value.- Return type:
- classmethod from_px(value)[source]
Get instance from
px
(pixel) value.- Parameters:
value (float) –
px
value.- Return type:
- get_value_cm()[source]
Gets instance value converted to
cm
units.- Returns:
Value in
cm
units.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to
mm
units.- Returns:
Value in
mm
units.- Return type:
int
- get_value_mm100()[source]
Gets instance value converted to
1/100th mm
units.- Returns:
Value in
1/100th mm
units.- Return type:
int
- get_value_pt()[source]
Gets instance value in
pt
(point) units.- Returns:
Value in
pt
units.- Return type:
int
- get_value_px()[source]
Gets instance value in
px
(pixel) units.- Returns:
Value in
px
units.- Return type:
int
- value: float
Float value.
- class ooodev.units.UnitT[source]
Protocol Class for units.
See also
UnitT
- get_value_mm()[source]
Gets instance value converted to Size in
mm
units.- Returns:
Value in
mm
units.- Return type:
float
- get_value_mm100()[source]
Gets instance value converted to Size in
1/100th mm
units.- Returns:
Value in
1/100th mm
units.- Return type:
int
- get_value_pt()[source]
Gets instance value converted to Size in
pt
(point) units.- Returns:
Value in
pt
units.- Return type:
float
- get_value_px()[source]
Gets instance value in
px
(pixel) units.- Returns:
Value in
px
units.- Return type:
float
- property value: float | int
Unit actual value. Generally a
float
orint
- Return type:
float | int