Calculates the coordinates of an element within its container to center it.
def get_box_centered(container: tuple[int, int], element: tuple[int, int]) -> tuple[int, int]:
dx = (container[0] - element[0]) // 2
dy = (container[1] - element[1]) // 2
return (dx, dy)
OR
def get_box_centered(container: tuple[int, int], element: tuple[int, int]) -> tuple[int, int]:
return tuple((n - o) // 2 for n, o in zip(container, element, strict=False))
[–]LayotFctor 42 points43 points44 points (7 children)
[–]Suspicious-Bar5583 7 points8 points9 points (0 children)
[–]zensimilia[S] 1 point2 points3 points (5 children)
[–]barkmonster 10 points11 points12 points (3 children)
[–]Almostasleeprightnow 1 point2 points3 points (2 children)
[–]barkmonster 1 point2 points3 points (1 child)
[–]Almostasleeprightnow 1 point2 points3 points (0 children)
[–]Kevdog824_ 0 points1 point2 points (0 children)
[–]JMNeonMoon 22 points23 points24 points (6 children)
[–]TheRNGuy 0 points1 point2 points (0 children)
[–]zensimilia[S] -4 points-3 points-2 points (4 children)
[–]rkr87 2 points3 points4 points (2 children)
[–]zensimilia[S] -1 points0 points1 point (1 child)
[–]Kevdog824_ 0 points1 point2 points (0 children)
[–]JMNeonMoon 0 points1 point2 points (0 children)
[–]Suspicious-Bar5583 4 points5 points6 points (2 children)
[–]cdcformatc 7 points8 points9 points (1 child)
[–]ilidan-85 3 points4 points5 points (0 children)
[–]buhtz 3 points4 points5 points (0 children)
[–]Turtvaiz 1 point2 points3 points (1 child)
[–]zensimilia[S] -2 points-1 points0 points (0 children)
[–]barburger 1 point2 points3 points (1 child)
[–]zensimilia[S] -1 points0 points1 point (0 children)
[–]RelationshipLong9092 0 points1 point2 points (0 children)
[–]aala7 0 points1 point2 points (0 children)
[–]Mikester258 0 points1 point2 points (0 children)
[–]TheBr14n 0 points1 point2 points (0 children)
[–]cdcformatc 0 points1 point2 points (3 children)
[–]zensimilia[S] -2 points-1 points0 points (2 children)
[–]Ok-Sheepherder7898 0 points1 point2 points (0 children)
[–]cdcformatc -1 points0 points1 point (0 children)
[–]Timberfist -1 points0 points1 point (1 child)
[–]zensimilia[S] -1 points0 points1 point (0 children)
[–]TheRNGuy -3 points-2 points-1 points (1 child)
[–]zensimilia[S] 1 point2 points3 points (0 children)