arcade
arcade copied to clipboard
Add camera stack for better context switching and safer draw loops
Currently, only the currently active camera is stored. It would be ideal if more information were stored about every camera activation during a draw loop.
An example of the kind of issue the camera stack fixes:
Window draw call
self.clear()
self.camera_b.position = self.center
self.camera_b.use()
arcade.draw_rect_filled(self.rectangle, (255, 0, 0, 125), self.angle)
with self.camera_a.activate():
self.camera_b.position = 100, 100
arcade.draw_rect_filled(self.rectangle, (255, 0, 0, 255), self.angle)
arcade.draw_rect_filled(self.rectangle, (255, 0, 0, 125), self.angle)
Current technically correct behaviour
https://github.com/pythonarcade/arcade/assets/86714785/3f4a9644-6479-4b8c-ae98-c6f98f10e880
Improved behaviour post-stack implimentation
https://github.com/pythonarcade/arcade/assets/86714785/1b4bed2f-cc56-4240-99c7-5bcb1e380e45
It also allows for better camera context mangers i.e.
with self.camera:
...
rather than
with self.camera.activate():
...