Skip to content

fixing the positioning algorithm in Camera2D.match_target for #2558 #2646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions arcade/camera/camera_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -451,7 +453,7 @@ def update_values(
self.scissor = value

if position:
self.position = value.center
self.position = Vec2(-self._projection_data.left, -self._projection_data.bottom)

def aabb(self) -> Rect:
"""
Expand Down
Loading