Skip to content

other

Classes:

  • Coordinate

    Positive set of (x, y) coordinates.

  • Position

    Positive set of an (x,y) offset relative to the top left corner of an area.

  • Size

    Positive set of an (x,y), (horizontal,vertical), size of an area.

Coordinate

Coordinate(other: tuple[int, int] | Self)
Coordinate(x: int, y: int)
Coordinate(x_or_self: int | tuple[int, int] | Self, y: int | None = None)

Positive set of (x, y) coordinates.

Raises:

Attributes:

  • x (int) –

    Horizontal coordinate.

  • y (int) –

    Vertical coordinate.

Source code in jetpytools/enums/other.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def __init__(self, x_or_self: int | tuple[int, int] | Self, y: int | None = None, /) -> None:
    if isinstance(x_or_self, int):
        x = x_or_self
    else:
        x, y = x_or_self if isinstance(x_or_self, tuple) else (x_or_self.x, x_or_self.y)

    if y is None:
        from ..exceptions import CustomValueError

        raise CustomValueError("y coordinate must be defined!", self.__class__)

    if x < 0 or y < 0:
        from ..exceptions import CustomValueError

        raise CustomValueError("Values can't be negative!", self.__class__)

    self.x = x
    self.y = y

x instance-attribute

x: int = x

Horizontal coordinate.

y instance-attribute

y: int = y

Vertical coordinate.

Position

Position(other: tuple[int, int] | Self)
Position(x: int, y: int)
Position(x_or_self: int | tuple[int, int] | Self, y: int | None = None)

Bases: Coordinate

Positive set of an (x,y) offset relative to the top left corner of an area.

Attributes:

  • x (int) –

    Horizontal coordinate.

  • y (int) –

    Vertical coordinate.

Source code in jetpytools/enums/other.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def __init__(self, x_or_self: int | tuple[int, int] | Self, y: int | None = None, /) -> None:
    if isinstance(x_or_self, int):
        x = x_or_self
    else:
        x, y = x_or_self if isinstance(x_or_self, tuple) else (x_or_self.x, x_or_self.y)

    if y is None:
        from ..exceptions import CustomValueError

        raise CustomValueError("y coordinate must be defined!", self.__class__)

    if x < 0 or y < 0:
        from ..exceptions import CustomValueError

        raise CustomValueError("Values can't be negative!", self.__class__)

    self.x = x
    self.y = y

x instance-attribute

x: int = x

Horizontal coordinate.

y instance-attribute

y: int = y

Vertical coordinate.

Size

Size(other: tuple[int, int] | Self)
Size(x: int, y: int)
Size(x_or_self: int | tuple[int, int] | Self, y: int | None = None)

Bases: Coordinate

Positive set of an (x,y), (horizontal,vertical), size of an area.

Attributes:

  • x (int) –

    Horizontal coordinate.

  • y (int) –

    Vertical coordinate.

Source code in jetpytools/enums/other.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def __init__(self, x_or_self: int | tuple[int, int] | Self, y: int | None = None, /) -> None:
    if isinstance(x_or_self, int):
        x = x_or_self
    else:
        x, y = x_or_self if isinstance(x_or_self, tuple) else (x_or_self.x, x_or_self.y)

    if y is None:
        from ..exceptions import CustomValueError

        raise CustomValueError("y coordinate must be defined!", self.__class__)

    if x < 0 or y < 0:
        from ..exceptions import CustomValueError

        raise CustomValueError("Values can't be negative!", self.__class__)

    self.x = x
    self.y = y

x instance-attribute

x: int = x

Horizontal coordinate.

y instance-attribute

y: int = y

Vertical coordinate.