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

Feature request: Ability to set the pixel density of the HTML canvas #2987

Open
1 of 11 tasks
setanarut opened this issue May 8, 2024 · 1 comment
Open
1 of 11 tasks

Comments

@setanarut
Copy link
Contributor

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

What feature would you like to be added?

Feature request: Ability to set the pixel density of the HTML canvas. At resolutions with pixel density greater than one, Ebitengine always scales the HTML Canvas size (Canvas size * DeviceScaleFactor). It would be nice to have an option to disable this. The equivalent of pixelDensity() in the p5.js library.

Additional info

The canvas's width and height properties are set to 800 because you are running this sketch on a high DPI (i.e. Apple Retina) display. When p5.js detects this it sets pixel density to 2 by default so it's taking 800 pixel square of graphics and squishing it into a 400 "pixel" square on the screen. If you want an image that is exactly 400 actual pixels, you could set pixel density to 1 in your setup() function: pixelDensity(1).

-- stackoverflow.com/a/69890360

Why is this needed?

Reasons for this feature:

  • Large-sized HTML canvases cause dramatic GPU usage.
  • Energy savings for portable devices.
  • Higher FPS performance.
@hajimehoshi
Copy link
Owner

hajimehoshi commented May 9, 2024

Adjusting the size of the framebuffer would be a good feature not only for browsers but also for any environments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants