Skip to content

Commit 9ef0a84

Browse files
committed
fixing the positioning algorithm in Camera2D.match_target for #2558
1 parent 94c4280 commit 9ef0a84

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

arcade/camera/camera_2d.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ def equalise(self) -> None:
330330
x, y = self._projection_data.rect.x, self._projection_data.rect.y
331331
self._projection_data.rect = XYWH(x, y, self.viewport_width, self.viewport_height)
332332

333+
equalize = equalise
334+
333335
def match_window(
334336
self,
335337
viewport: bool = True,
@@ -348,8 +350,8 @@ def match_window(
348350
On by default
349351
scissor: Flag whether to also equalize the scissor box to the viewport.
350352
On by default
351-
position: Flag whether to also center the camera to the viewport.
352-
Off by default
353+
position: Flag whether to position the camera so that (0.0, 0.0) is in
354+
the bottom-left
353355
aspect: The ratio between width and height that the viewport should
354356
be constrained to. If unset then the viewport just matches the window
355357
size. The aspect ratio describes how much larger the width should be
@@ -382,8 +384,8 @@ def match_target(
382384
match the render target.
383385
The projection center stays fixed, and the new projection matches only in size.
384386
scissor: Flag whether to update the scissor value.
385-
position: Flag whether to also center the camera to the value.
386-
Off by default
387+
position: Flag whether to position the camera so that (0.0, 0.0) is in
388+
the bottom-left
387389
aspect: The ratio between width and height that the value should
388390
be constrained to. i.e. for an aspect ratio of ``4:3`` you should
389391
input ``4.0/3.0`` or ``1.33333...``. Cannot be equal to zero.
@@ -424,8 +426,8 @@ def update_values(
424426
projection: Flag whether to equalize the size of the projection to match the value.
425427
The projection center stays fixed, and the new projection matches only in size.
426428
scissor: Flag whether to update the scissor value.
427-
position: Flag whether to also center the camera to the value.
428-
Off by default
429+
position: Flag whether to position the camera so that (0.0, 0.0) is in
430+
the bottom-left
429431
aspect: The ratio between width and height that the value should
430432
be constrained to. i.e. for an aspect ratio of ``4:3`` you should
431433
input ``4.0/3.0`` or ``1.33333...``. Cannot be equal to zero.
@@ -451,7 +453,7 @@ def update_values(
451453
self.scissor = value
452454

453455
if position:
454-
self.position = value.center
456+
self.position = -self._projection_data.left, -self._projection_data.bottom
455457

456458
def aabb(self) -> Rect:
457459
"""

0 commit comments

Comments
 (0)