Skip to content

Implement canvas.set_zoom() and canvas.get_size_info() - #123

Merged
almarklein merged 10 commits into
mainfrom
zoom
Dec 2, 2026
Merged

almarklein merged 10 commits into
mainfrom
zoom

Conversation

@almarklein

@almarklein almarklein commented Oct 30, 2025 •

Copy link
Copy Markdown
Member

Ref #114

Add canvas.get_zoom() and canvas.set_zoom(). The logic is all in the base class; backends don't need to know about this.

This works, and I think it's a useful addition. What remains is that all events that include positions (pointer pos) should be updated to scale the positions.

@almarklein almarklein changed the title Implement canvas zoom Implement canvas.set_zoom() and canvas.get_size_info() Dec 1, 2026
@almarklein

Copy link
Copy Markdown
Member Author

Revived this PR. I also implemented canvas.get_size_info() because that gives one endpoint to give users a way to get all the size info they could need, which avoids having get_zoom() , get_resolution_scale() etc. We could in time deprecated get_logical_size() and get_pixel_ratio() as well, but let's just keep these for now.

@almarklein
almarklein marked this pull request as ready for review December 1, 2026 10:11
@almarklein
almarklein requested a review from Vipitis December 1, 2026 10:11
Comment thread rendercanvas/base.py Resolved
@Vipitis

Vipitis commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Additional discussion in the name 'set_zoom' at first I thought it is a crop in. But it's more of a scale, I tried this with some pygfx examples that have text elements and you basically change the size of these elements.

I guess it's user choice and it could be a crop in zoom too. More of a personal feeling, if this is established nomenclature from like web canvas for example that's all fine.

@almarklein

Copy link
Copy Markdown
Member Author

Yeah the name is copied from how browsers call it. It does the same thing: reducing the logical size, so everything looks bigger.

Screenshot 2026-12-02 at 11 07 35

Comment thread rendercanvas/core/events.py Resolved

@Vipitis Vipitis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit then all good!

@almarklein
almarklein merged commit 4d6b108 into main Dec 2, 2026
29 checks passed
@almarklein
almarklein deleted the zoom branch December 2, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants