From b37b2c2c8f248d08568ffd47e47fa26ad7aa47c0 Mon Sep 17 00:00:00 2001 From: Paul Craven Date: Fri, 10 Jan 2025 15:22:13 -0600 Subject: [PATCH] Update --- arcade/application.py | 10 +++++++++- arcade/camera/camera_2d.py | 8 ++++---- arcade/camera/perspective.py | 6 +++--- arcade/camera/projection_functions.py | 16 ++++++++-------- arcade/examples/gl/3d_sphere.py | 2 +- arcade/examples/gl/normal_mapping_simple.py | 2 +- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/arcade/application.py b/arcade/application.py index 9c5a16a587..435ec8bd01 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -8,7 +8,7 @@ import logging import os import time -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Sequence import pyglet import pyglet.gl as gl @@ -318,6 +318,14 @@ def __init__( # rendered to the window when the event loop starts. self._start_finish_render_data: StartFinishRenderData | None = None + def _create(self) -> None: + """Internal function to create the window.""" + pass + + def _recreate(self, changes: Sequence[str]) -> None: + """Internal function to recreate the window.""" + pass + @property def current_view(self) -> View | None: """ diff --git a/arcade/camera/camera_2d.py b/arcade/camera/camera_2d.py index ee0e43e202..b8d37f1cf6 100644 --- a/arcade/camera/camera_2d.py +++ b/arcade/camera/camera_2d.py @@ -900,7 +900,7 @@ def top_left(self, new_corner: Point2): left = self.left x, y = new_corner - self.position = (x - ux * top - rx * left, y - uy * top - ry * left) + self.position = Vec2(x - ux * top - rx * left, y - uy * top - ry * left) # top_center @property @@ -982,7 +982,7 @@ def bottom_right(self, new_corner: Point2): right = self.right x, y = new_corner - self.position = ( + self.position = Vec2( x - ux * bottom - rx * right, y - uy * bottom - ry * right, ) @@ -1003,7 +1003,7 @@ def bottom_center(self, new_bottom: Point2): bottom = self.bottom x, y = new_bottom - self.position = x - ux * bottom, y - uy * bottom + self.position = Vec2(x - ux * bottom, y - uy * bottom) # bottom_left @property @@ -1044,4 +1044,4 @@ def center_left(self, new_left: Point2): left = self.left x, y = new_left - self.position = x - uy * left, y + ux * left + self.position = Vec2(x - uy * left, y + ux * left) diff --git a/arcade/camera/perspective.py b/arcade/camera/perspective.py index 43bcbd7540..e297b4a586 100644 --- a/arcade/camera/perspective.py +++ b/arcade/camera/perspective.py @@ -182,15 +182,15 @@ def project(self, world_coordinate: Point) -> Vec2: Returns: A 2D screen pixel coordinate. """ - x, y, *z = world_coordinate + x, y, *zp = world_coordinate z = ( ( 0.5 * self.viewport.height / tan(radians(0.5 * self._projection.fov / self._view.zoom)) ) - if not z - else z[0] + if not zp + else zp[0] ) _projection = generate_perspective_matrix(self._projection, self._view.zoom) diff --git a/arcade/camera/projection_functions.py b/arcade/camera/projection_functions.py index 5a96b9f31a..23e2cf185e 100644 --- a/arcade/camera/projection_functions.py +++ b/arcade/camera/projection_functions.py @@ -125,8 +125,8 @@ def project_orthographic( view_matrix: Mat4, projection_matrix: Mat4, ) -> Vec2: - x, y, *z = world_coordinate - z = 0.0 if not z else z[0] + x, y, *zp = world_coordinate + z = 0.0 if not zp else zp[0] world_position = Vec4(x, y, z, 1.0) @@ -144,8 +144,8 @@ def unproject_orthographic( view_matrix: Mat4, projection_matrix: Mat4, ) -> Vec3: - x, y, *z = screen_coordinate - z = 0.0 if not z else z[0] + x, y, *zp = screen_coordinate + z = 0.0 if not zp else zp[0] screen_x = 2.0 * (x - viewport[0]) / viewport[2] - 1 screen_y = 2.0 * (y - viewport[1]) / viewport[3] - 1 @@ -165,8 +165,8 @@ def project_perspective( view_matrix: Mat4, projection_matrix: Mat4, ) -> Vec2: - x, y, *z = world_coordinate - z = 1.0 if not z else z[0] + x, y, *zp = world_coordinate + z = 1.0 if not zp else zp[0] world_position = Vec4(x, y, z, 1.0) @@ -188,8 +188,8 @@ def unproject_perspective( view_matrix: Mat4, projection_matrix: Mat4, ) -> Vec3: - x, y, *z = screen_coordinate - z = 1.0 if not z else z[0] + x, y, *zp = screen_coordinate + z = 1.0 if not zp else zp[0] screen_x = 2.0 * (x - viewport[0]) / viewport[2] - 1 screen_y = 2.0 * (y - viewport[1]) / viewport[3] - 1 diff --git a/arcade/examples/gl/3d_sphere.py b/arcade/examples/gl/3d_sphere.py index 1b155f7586..98a1d4db7a 100644 --- a/arcade/examples/gl/3d_sphere.py +++ b/arcade/examples/gl/3d_sphere.py @@ -169,7 +169,7 @@ def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers): def on_mouse_release(self, x, y, button, modifiers): self.drag_time = None - def on_mouse_scroll(self, x: int, y: int, scroll_x: int, scroll_y: int): + def on_mouse_scroll(self, x: int, y: int, scroll_x: float, scroll_y: float): self.vert_count = clamp(self.vert_count + scroll_y / 500, 0.0, 1.0) diff --git a/arcade/examples/gl/normal_mapping_simple.py b/arcade/examples/gl/normal_mapping_simple.py index 93f6d678ef..26b0a2d622 100644 --- a/arcade/examples/gl/normal_mapping_simple.py +++ b/arcade/examples/gl/normal_mapping_simple.py @@ -130,7 +130,7 @@ def on_mouse_motion(self, x: int, y: int, dx: int, dy: int): # (0.0, 0.0) is bottom left, (1.0, 1.0) is top right self.mouse_x, self.mouse_y = x / self.width, y / self.height - def on_mouse_scroll(self, x: int, y: int, scroll_x: int, scroll_y: int): + def on_mouse_scroll(self, x: int, y: int, scroll_x: float, scroll_y: float): """Zoom in/out with the mouse wheel.""" self.mouse_z += scroll_y * 0.05