From 2d2982c546840565260a573b920f9c95bffb5404 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 6 Apr 2024 18:53:10 +0800 Subject: [PATCH] =?UTF-8?q?camera=20=E6=B2=A1=E5=95=A5=E5=BF=85=E8=A6=81?= =?UTF-8?q?=EF=BC=8C=E6=89=AC=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maker-py/camera.py | 75 ---------------------------------------------- maker-py/main.py | 10 +++++++ 2 files changed, 10 insertions(+), 75 deletions(-) delete mode 100644 maker-py/camera.py diff --git a/maker-py/camera.py b/maker-py/camera.py deleted file mode 100644 index 0b8d77a..0000000 --- a/maker-py/camera.py +++ /dev/null @@ -1,75 +0,0 @@ -from typing import Tuple, Optional - -# from pyglet.gl import gl -from pyglet.math import Mat4, Vec3 -from pyglet.graphics import Group - - -class GroupCamera(Group): - """ - A camera by group - can be used by just added to your widget - """ - - def __init__( - self, - window, - order: int = 0, - parent: Optional[Group] = None, - view_x: Optional[int] = 0, - view_y: Optional[int] = 0, - zoom: Optional[float] = 1.0, - min_zoom: Optional[float] = 1.0, - max_zoom: Optional[float] = 1.0, - ): - super().__init__(order=order, parent=parent) - self._window = window - self._previous_view = None - - self._view_x = view_x or 0 - self._view_y = view_y or 0 - self._zoom = zoom or 1.0 - self.min_zoom = min_zoom or 1.0 - self.max_zoom = max_zoom or 1.0 - - @property - def view_x(self) -> int: - return self._view_x - - @view_x.setter - def view_x(self, value: int): - self._view_x = value - - @property - def view_y(self) -> int: - return self._view_y - - @view_y.setter - def view_y(self, value: int): - self._view_y = value - - @property - def zoom(self) -> float: - return min(max(self._zoom, self.min_zoom), self.max_zoom) - - @zoom.setter - def zoom(self, value: float): - self._zoom = value - - def reset(self): - self._view_x = 0 - self._view_y = 0 - self.zoom = 1 - - def set_state(self): - self._previous_view = self._window.view - - view = Mat4.from_translation(Vec3(self._view_x, self._view_y, 0)) - if self._zoom == 1.0: - self._window.view = view - else: - view = view.scale(Vec3(self._zoom, self._zoom, 1)) - self._window.view = view - - def unset_state(self): - self._window.view = self._previous_view diff --git a/maker-py/main.py b/maker-py/main.py index 23ac7c0..350e848 100644 --- a/maker-py/main.py +++ b/maker-py/main.py @@ -137,6 +137,16 @@ class MainWindow(Window): self.num_dict = {} self.num_batch = Batch() self.num_group = Group(parent=self.main_group, order=10) + # 用于覆盖掉 num 顶上多出来的部分 + self.num_cover = Rectangle( + x=40, + y=50, + width=35, + height=20, + color=(0, 255, 255, 255), + batch=self.num_batch, + group=self.num_group, + ) # 从大到小 num_group = Group(parent=self.num_group, order=10) for i in range(256):