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

New feature improved automatic resizing #72

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Mohamed-Waiel-Shikfa
Copy link
Contributor

Tries to address:

My approach:
if user wants cmu_graphics to handle resizing automatically for him,
then when screen resize:

  • draw everything using the previous code at starting width and height size
  • once the code gives back a pygame image scale that image to the new width and height
  • if user want a same aspect ratio, scale to the smallest of x-scale and y-scale and offset the image so it is centred

I implemented the above faithfully but unfortunately it didn't work as I excepted and created a bug where the screen would constantly flicker.
I feel like there is a not so complicated way to fix this but I am unsure as to what it would be.
Once fixed this would be a great new feature to merge.

These are Booleans that can be accessed with app.autoResize and app.keepAspectRatio respectively and will let cmu_graphics know if and how the user wants cmu_graphics to handle resizing automatically behind the scenes.
Logic done but not working as expected so bug fixing time it is.
@linxuanm
Copy link
Contributor

linxuanm commented Nov 8, 2024

Hi! Are you still working on this? If not, do you mind if I continue off this PR? Thanks!

@Mohamed-Waiel-Shikfa
Copy link
Contributor Author

I mean I don't mind but would like to stay in the loop.

My main issue is that I tried my best understanding the current drawing pipeline (from using pycairo to generate the image in the buffer and then passing that to pygame) but I am still not fully comfortable with it.

The way I tried implementing this feature until now is that if the user wants the canvas to resize automatically, we always draw to the starting size canvas with pycairo, then we transforme that to a pygame image and scale it by the (current width and height)/(starting width and height).

Does this make sense? Please let me know.

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