You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use Camera2D for the first time (x-ref #2557) and wanted to have a solar system with sun at world position (0, 0) and earth at world position (1, 0) etc, but then have it displayed on a larger window e.g. with 800 x 600 pixels.
I tried to create a Camera2D for this that does this world to screen pixel mapping like this:
My understanding from the docs is that camera.projection should be the Rect in world coordinates and camera.viewport the Rect in screen pixel coordinates. So far it looks good to me, what I expected.
However then when I try to use this to draw it doesn't do what I expected, to put the sun from world position (0, 0) to the screen center at pixel position (400, 300).
One more issue I ran into is that arcade.draw_circle_filled will only use four points now.
Is this something that should be improved that to compute how many points to use for the screen render first the transform to screen pixel coordinates is applied?
Okay, Github initially hid the extra messages, so my first response wasn't helpful.
The reason it sits in the center of the viewport is to mimic Arcade's default behavior of having (0.0, 0.0) in the bottom left corner. Maybe this should be changed if you set the projection. However, the center of the projection doesn't really make sense either.
The documentation for cameras is very lacking at the moment as I depriortised it to get 3.0 out. It's on my todo list.
I'm reviewing issues because there are so many things I want to do before 4.0 comes out. Getting this working nice is on the list. I think this may be solved already. If it isn't, for future me, the camera should always position itself in the init so that (0.0, 0.0) is the bottom left corner of the screen so it matches the default behavior of arcade. This wouldn't solve this person's issue since they want 0.0, 0.0 to be the center of the screen, but I think matching arcade's default behavior is more important.
Activity
cdeil commentedon Feb 10, 2025
I see now, the issue is that
camera.positionis set to the viewport center:arcade/arcade/camera/camera_2d.py
Lines 138 to 139 in f4f4521
I had expected that when I pass
projectionit's auto-set to the projection center.If I change to this everything works as expected:
Does it make sense to init
positionas now or should it be changed to init based on projection center?Maybe at least the docstring could be clarified what "XY plane" means?
arcade/arcade/camera/camera_2d.py
Lines 61 to 62 in f4f4521
Either way, I'm happy that I have a working solution with a camera. :-)
cdeil commentedon Feb 10, 2025
One more issue I ran into is that
arcade.draw_circle_filledwill only use four points now.Is this something that should be improved that to compute how many points to use for the screen render first the transform to screen pixel coordinates is applied?
As workaround I now use
num_segments=30at the moment. ( my script so far: https://gist.github.com/cdeil/8fa5dab682ee4fea0e561f52b9764c11 )einarf commentedon Feb 10, 2025
@DragonMoffon
DragonMoffon commentedon Feb 11, 2025
Okay, Github initially hid the extra messages, so my first response wasn't helpful.
The reason it sits in the center of the viewport is to mimic Arcade's default behavior of having (0.0, 0.0) in the bottom left corner. Maybe this should be changed if you set the projection. However, the center of the projection doesn't really make sense either.
The documentation for cameras is very lacking at the moment as I depriortised it to get 3.0 out. It's on my todo list.
fixing the positioning algorithm in `Camera2D.match_target` for #2558
fixing the positioning algorithm in `Camera2D.match_target` for #2558 (…
DragonMoffon commentedon Oct 8, 2025
I'm reviewing issues because there are so many things I want to do before 4.0 comes out. Getting this working nice is on the list. I think this may be solved already. If it isn't, for future me, the camera should always position itself in the init so that (0.0, 0.0) is the bottom left corner of the screen so it matches the default behavior of arcade. This wouldn't solve this person's issue since they want 0.0, 0.0 to be the center of the screen, but I think matching arcade's default behavior is more important.
better position doc string as part of #2558
Camera2d requested additions (#2796)
pvcraven commentedon Oct 8, 2026
Closing as fixed by #2796. A new
Camera2Dnow has (0, 0) at the bottom left of its viewport by default.