Skip to content

Commit f5b6228

Browse files
authored
fixing the positioning algorithm in Camera2D.match_target for #2558 (#2646)
* fixing the positioning algorithm in `Camera2D.match_target` for #2558 * vec2 whoops
1 parent 9c90129 commit f5b6228

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
@@ -331,6 +331,8 @@ def equalise(self) -> None:
331331
x, y = self._projection_data.rect.x, self._projection_data.rect.y
332332
self._projection_data.rect = XYWH(x, y, self.viewport_width, self.viewport_height)
333333

334+
equalize = equalise
335+
334336
def match_window(
335337
self,
336338
viewport: bool = True,
@@ -349,8 +351,8 @@ def match_window(
349351
On by default
350352
scissor: Flag whether to also equalize the scissor box to the viewport.
351353
On by default
352-
position: Flag whether to also center the camera to the viewport.
353-
Off by default
354+
position: Flag whether to position the camera so that (0.0, 0.0) is in
355+
the bottom-left
354356
aspect: The ratio between width and height that the viewport should
355357
be constrained to. If unset then the viewport just matches the window
356358
size. The aspect ratio describes how much larger the width should be
@@ -383,8 +385,8 @@ def match_target(
383385
match the render target.
384386
The projection center stays fixed, and the new projection matches only in size.
385387
scissor: Flag whether to update the scissor value.
386-
position: Flag whether to also center the camera to the value.
387-
Off by default
388+
position: Flag whether to position the camera so that (0.0, 0.0) is in
389+
the bottom-left
388390
aspect: The ratio between width and height that the value should
389391
be constrained to. i.e. for an aspect ratio of ``4:3`` you should
390392
input ``4.0/3.0`` or ``1.33333...``. Cannot be equal to zero.
@@ -425,8 +427,8 @@ def update_values(
425427
projection: Flag whether to equalize the size of the projection to match the value.
426428
The projection center stays fixed, and the new projection matches only in size.
427429
scissor: Flag whether to update the scissor value.
428-
position: Flag whether to also center the camera to the value.
429-
Off by default
430+
position: Flag whether to position the camera so that (0.0, 0.0) is in
431+
the bottom-left
430432
aspect: The ratio between width and height that the value should
431433
be constrained to. i.e. for an aspect ratio of ``4:3`` you should
432434
input ``4.0/3.0`` or ``1.33333...``. Cannot be equal to zero.
@@ -452,7 +454,7 @@ def update_values(
452454
self.scissor = value
453455

454456
if position:
455-
self.position = value.center
457+
self.position = Vec2(-self._projection_data.left, -self._projection_data.bottom)
456458

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

0 commit comments

Comments
 (0)