maze: refactor move_to_center
This commit is contained in:
parent
f0d2949ce5
commit
0bc9777bfb
@ -197,10 +197,9 @@ def choose_plural(amount, declensions):
|
|||||||
|
|
||||||
def move_to_center(obj, scene_sz):
|
def move_to_center(obj, scene_sz):
|
||||||
"""Перемещает объект к центру"""
|
"""Перемещает объект к центру"""
|
||||||
bounds = bbox(obj)
|
x1, y1, x2, y2 = bbox(obj)
|
||||||
width = bounds[2] - bounds[0]
|
obj_sz = Coords(x2, y2) - Coords(x1, y1)
|
||||||
height = bounds[3] - bounds[1]
|
p = scene_sz // 2 - obj_sz // 2
|
||||||
p = scene_sz // 2 - Coords(width, height) // 2
|
|
||||||
moveObjectTo(obj, *p)
|
moveObjectTo(obj, *p)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user