From 9ef0a84da2f4d89baa24dc0d75173aeedfdec2d2 Mon Sep 17 00:00:00 2001 From: DragonMoffon Date: Fri, 4 Apr 2025 23:34:08 +1300 Subject: [PATCH 1/2] fixing the positioning algorithm in `Camera2D.match_target` for #2558 --- arcade/camera/camera_2d.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/arcade/camera/camera_2d.py b/arcade/camera/camera_2d.py index d0b048a9b..f99e38385 100644 --- a/arcade/camera/camera_2d.py +++ b/arcade/camera/camera_2d.py @@ -330,6 +330,8 @@ def equalise(self) -> None: x, y = self._projection_data.rect.x, self._projection_data.rect.y self._projection_data.rect = XYWH(x, y, self.viewport_width, self.viewport_height) + equalize = equalise + def match_window( self, viewport: bool = True, @@ -348,8 +350,8 @@ def match_window( On by default scissor: Flag whether to also equalize the scissor box to the viewport. On by default - position: Flag whether to also center the camera to the viewport. - Off by default + position: Flag whether to position the camera so that (0.0, 0.0) is in + the bottom-left aspect: The ratio between width and height that the viewport should be constrained to. If unset then the viewport just matches the window size. The aspect ratio describes how much larger the width should be @@ -382,8 +384,8 @@ def match_target( match the render target. The projection center stays fixed, and the new projection matches only in size. scissor: Flag whether to update the scissor value. - position: Flag whether to also center the camera to the value. - Off by default + position: Flag whether to position the camera so that (0.0, 0.0) is in + the bottom-left aspect: The ratio between width and height that the value should be constrained to. i.e. for an aspect ratio of ``4:3`` you should input ``4.0/3.0`` or ``1.33333...``. Cannot be equal to zero. @@ -424,8 +426,8 @@ def update_values( projection: Flag whether to equalize the size of the projection to match the value. The projection center stays fixed, and the new projection matches only in size. scissor: Flag whether to update the scissor value. - position: Flag whether to also center the camera to the value. - Off by default + position: Flag whether to position the camera so that (0.0, 0.0) is in + the bottom-left aspect: The ratio between width and height that the value should be constrained to. i.e. for an aspect ratio of ``4:3`` you should input ``4.0/3.0`` or ``1.33333...``. Cannot be equal to zero. @@ -451,7 +453,7 @@ def update_values( self.scissor = value if position: - self.position = value.center + self.position = -self._projection_data.left, -self._projection_data.bottom def aabb(self) -> Rect: """ From 57473b045738bb6597c0df878fb9b42833a8113f Mon Sep 17 00:00:00 2001 From: DragonMoffon Date: Fri, 4 Apr 2025 23:36:50 +1300 Subject: [PATCH 2/2] vec2 whoops --- arcade/camera/camera_2d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcade/camera/camera_2d.py b/arcade/camera/camera_2d.py index f99e38385..7b80bf1e9 100644 --- a/arcade/camera/camera_2d.py +++ b/arcade/camera/camera_2d.py @@ -453,7 +453,7 @@ def update_values( self.scissor = value if position: - self.position = -self._projection_data.left, -self._projection_data.bottom + self.position = Vec2(-self._projection_data.left, -self._projection_data.bottom) def aabb(self) -> Rect: """