swap_positions
Functionswap_positions(
state_1: State,
state_2: State,
t_start: float,
t_end: float,
easing: Optional[Dict[str, Callable[[float], float]]] = None
) -> Tuple[List[KeyState], List[KeyState]]
Swaps the positions of two elements with linear interpolation.
Returns two keystate lists for two separate VElements. This function assumes both State objects have a 'pos' attribute of type Point2D.
Parameters
-
state_1 - The base State of the first element.
-
state_2 - The base State of the second element.
-
t_start - Start time of the swap.
-
t_end - End time of the swap.
-
easing - Optional easing dict for position transitions.
Returns
Tuple of (keystates_for_elem1, keystates_for_elem2)
Examples
ks1, ks2 = swap_positions(circle1, square2, t_start=0.3, t_end=0.8)
elem1 = VElement().segment(ks1)
elem2 = VElement().segment(ks2)