psychos.visual.units.CMUnit#
- class psychos.visual.units.CMUnit(window: Window)[source]#
Bases:
UnitCentimeter (cm) unit system.
This unit system converts coordinates and sizes between centimeters and pixels using the screen’s physical dimensions and resolution (DPI).
1 cm corresponds to a specific number of pixels based on the screen’s DPI.
Methods
__init__(window)from_name(name, window)Instantiate a unit system class by name or return the instance if already provided.
inverse_transform(x, y)Convert coordinates from pixel values to units.
inverse_transform_size(width, height)Convert size from pixel values to units.
transform(x, y)Convert coordinates from units to pixel values.
transform_size(width, height)Convert size from units to pixel values.
Attributes
Calculate pixels per centimeter based on the current screen DPI.
- inverse_transform(x: int, y: int) Tuple[float, float][source]#
Convert coordinates from pixel values to units.
- inverse_transform_size(width: int, height: int) Tuple[float, float][source]#
Convert size from pixel values to units.