feat: add zoom

This commit is contained in:
2025-12-19 23:26:25 +03:00
parent d04d4a0cdc
commit 48885d567a
3 changed files with 42 additions and 14 deletions

View File

@@ -31,6 +31,7 @@ class Simulator:
self.angle = 0.0
self.current_x = 0.0
self.current_y = 0.0
self.zoom = 1
# Создаем папку для изображений, если её нет
os.makedirs('./images', exist_ok=True)
@@ -68,8 +69,8 @@ class Simulator:
Обновляет траекторию полета беспилотника
"""
# Обновляем текущие координаты
self.current_x += dx
self.current_y += dy
self.current_x += dx * self.zoom
self.current_y += dy * self.zoom
def update_map(self):
"""
@@ -88,14 +89,23 @@ class Simulator:
self.angle += dangle
# print(f" [Simulator] angle: {self.angle / math.pi * 180:.1f}°")
velocity = max(velocity, 10)
dx = math.cos(math.pi / 2 + self.angle) * velocity
dy = math.sin(math.pi / 2 + self.angle) * velocity
dx = math.cos(math.pi / 2 + self.angle) * velocity / self.zoom
dy = math.sin(math.pi / 2 + self.angle) * velocity / self.zoom
# print(" [Simulator] dx, dy:", [dx, dy])
self.update_trajectory(dx, dy)
action.move_by_offset(-dx, dy)
action.release()
action.perform()
# print(f" [Simulator] Position: {self.current_x}, {self.current_y}")
def change_zoom(self, direction: str = 'down'):
""" Изменение масштаба """
self.yandexMap.scroll(0.5, 0.5, 2, direction == 'down')
sleep(0.4)
if direction == 'down':
self.zoom /= 2
else:
self.zoom *= 2
def get_photo(self) -> Image.Image:
png = self.yandexMap.driver.get_screenshot_as_png()