psychos.visual.units.DegUnit#

class psychos.visual.units.DegUnit(window: Window)[source]#

Bases: Unit

Degrees of visual angle (deg) unit system.

This unit system converts degrees of visual angle into pixels based on the distance between the viewer and the screen.

It requires a known distance from the screen to accurately compute the size in pixels.

__init__(window: Window)#

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

distance_cm

Get the distance from the viewer to the screen in centimeters.

pixels_per_cm

Calculate pixels per centimeter based on the current screen DPI.

property distance_cm: float#

Get the distance from the viewer to the screen in centimeters.

inverse_transform(x: int, y: int) Tuple[float, float][source]#

Convert coordinates from pixel values to units.

Parameters:
  • x (int) – The x-coordinate in pixels.

  • y (int) – The y-coordinate in pixels.

Returns:

The coordinates in the unit system.

Return type:

Tuple[float, float]

inverse_transform_size(width: int, height: int) Tuple[float, float][source]#

Convert size from pixel values to units.

Parameters:
  • width (int) – The width in pixels.

  • height (int) – The height in pixels.

Returns:

The width and height in the unit system.

Return type:

Tuple[float, float]

property pixels_per_cm: float#

Calculate pixels per centimeter based on the current screen DPI.

transform(x: float, y: float) Tuple[int, int][source]#

Convert coordinates from units to pixel values.

Parameters:
  • x (float) – The x-coordinate.

  • y (float) – The y-coordinate.

Returns:

The pixel coordinates.

Return type:

Tuple[int, int]

transform_size(width: float, height: float) Tuple[int, int][source]#

Convert size from units to pixel values.

Parameters:
  • width (float) – The width in the unit system.

  • height (float) – The height in the unit system.

Returns:

The width and height in pixel values.

Return type:

Tuple[int, int]