Skip to content

Waypoint

Module: terminaltexteffects.engine.motion

A Waypoint comprises a coordinate, speed, and, optionally, bezier control point(s).

Parameters:

Name Type Description Default
waypoint_id str

unique identifier for the waypoint

required
coord Coord

coordinate

required
bezier_control tuple[Coord, ...] | Coord | None

coordinate of the control point for a bezier curve. Defaults to None.

None
Source code in terminaltexteffects/engine/motion.py
@dataclass
class Waypoint:
    """A Waypoint comprises a coordinate, speed, and, optionally, bezier control point(s).

    Args:
        waypoint_id (str): unique identifier for the waypoint
        coord (Coord): coordinate
        bezier_control (tuple[Coord, ...] | Coord | None): coordinate of the control point for a bezier curve. Defaults to None.
    """

    waypoint_id: str
    coord: Coord
    bezier_control: tuple[Coord, ...] | Coord | None = None

    def __post_init__(self) -> None:
        if self.bezier_control and isinstance(self.bezier_control, Coord):
            self.bezier_control = (self.bezier_control,)

    def __eq__(self, other: typing.Any) -> bool:
        if not isinstance(other, Waypoint):
            return NotImplemented
        return self.coord == other.coord

    def __hash__(self):
        return hash(self.waypoint_id)