def get_square_rect(self, sq_str):
"""Вычисляет экранные координаты (x, y, w, h) клетки (например, 'e2')"""
board_rect = getattr(crop, 'last_board_rect', None) or getattr(crop, 'board_rect', None)
if not board_rect and hasattr(crop, 'find_chessboard_strictly_1to1'):
res = crop.find_chessboard_strictly_1to1()
if res and isinstance(res, tuple) and len(res) >= 1 and isinstance(res[0], (tuple, list)):
board_rect = res[0]
if not board_rect:
return None
bx, by, bw, bh = board_rect
sq_w = bw / 8.0
sq_h = bh / 8.0
file_idx = ord(sq_str[0]) - ord('a')
rank_idx = int(sq_str[1]) - 1
if self.my_color == 'w':
col = file_idx
row = 7 - rank_idx
else:
col = 7 - file_idx
row = rank_idx
x = int(bx + col * sq_w)
y = int(by + row * sq_h)
return (x, y, int(sq_w), int(sq_h))