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

VIDEORESIZE events #187

Open
TomFryers opened this issue Dec 18, 2024 · 0 comments
Open

VIDEORESIZE events #187

TomFryers opened this issue Dec 18, 2024 · 0 comments

Comments

@TomFryers
Copy link

Pygame supports creating resizable windows. However, I don't think these are getting passed through from the browser.

Here's an example that works on my desktop, but not through pygbag.

import asyncio

import pygame


def sane_font(width, height):
    return pygame.font.Font(None, round(min(height, width) * 0.2))


async def main():
    pygame.init()

    width = 1280
    height = 720
    S = pygame.display.set_mode((width, height), pygame.RESIZABLE)

    font = sane_font(width, height)
    while True:
        for event in pygame.event.get():
            if event.type == pygame.VIDEORESIZE:
                width, height = S.get_size()
                font = sane_font(width, height)
        S.fill((255, 255, 255))
        S.blit(font.render(f"{width} × {height}", True, (0, 0, 0)), (5, 5))
        pygame.display.update()
        await asyncio.sleep(0)


asyncio.run(main())

Pygbag does well at scaling up non-resizable windows, but where the author's gone to the trouble of handling resizes, crisp graphics would be really nice to have.

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

No branches or pull requests

1 participant