Skip to content

Commit 52406ae

Browse files
committed
Add projection validation to Camera2D.__init__
1 parent 9f25a68 commit 52406ae

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

arcade/camera/camera_2d.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,25 @@ def __init__(self, *,
6565
projection_data: Optional[OrthographicProjectionData] = None,
6666
render_target: Optional[Framebuffer] = None,
6767
window: Optional["Window"] = None):
68+
69+
if projection_data:
70+
left, right = projection_data.left, projection_data.right
71+
if projection_data.left == projection_data.right:
72+
raise ZeroProjectionDimension((
73+
f"projection width is 0 due to equal {left=}"
74+
f"and {right=} values"))
75+
bottom, top = projection_data.left, projection_data.right
76+
if bottom == top:
77+
raise ZeroProjectionDimension((
78+
f"projection height is 0 due to equal {bottom=}"
79+
f"and {top=}"))
80+
near, far = projection_data.near, projection_data.far
81+
if near == far:
82+
raise ZeroProjectionDimension(
83+
f"projection depth is 0 due to equal {near=}"
84+
f"and {far=} values"
85+
)
86+
6887
self._window: "Window" = window or get_window()
6988
self.render_target: Framebuffer = render_target or self._window.ctx.screen
7089
width, height = self.render_target.size

0 commit comments

Comments
 (0)