Skip to content
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

Support zoom in Camera #1964

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 7 additions & 1 deletion arcade/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import math
from typing import TYPE_CHECKING, List, Optional, Tuple, Union

from pyglet.math import Mat4, Vec2, Vec3
from pyglet.math import Mat4, Vec2, Vec3, Vec4

import arcade
from arcade.types import Point
Expand Down Expand Up @@ -552,6 +552,12 @@ def shake(self, velocity: Union[Vec2, tuple], speed: float = 1.5, damping: float
self.shake_damping = damping
self.shaking = True

def get_map_coordinates(self, camera_vector: Union[Vec2, tuple]) -> Vec2:
x, y = camera_vector
_x, _y = (x / self.viewport_width) * 2 - 1, (y / self.viewport_height) * 2 - 1
world_vector = ~(self._combined_matrix) @ Vec4(_x, _y, 1.0, 1.0)
return Vec2(world_vector.x, world_vector.y)

def use(self) -> None:
"""
Select this camera for use. Do this right before you draw.
Expand Down
Loading