-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[p5.js 2.0 RFC Proposal]: Allow access to context attributes in renderers #6781
Comments
For For For |
These were my main concern here, so that would totally work for me But for |
Ah sorry I thought by |
I'm not sure the Color module rewrite proposal will overlap with the color space setting here. What I'm thinking about in terms of new Color module is to make it more or less compatible with CSS colors and where sensible draw additional inspiration/ideas from color.js. For the canvas color space we can possibly change the default to p3 and fallback to srgb with something like this line. const colorSpace = window.matchMedia('(color-gamut: p3)').matches ? 'display-p3' : 'srgb'; And |
Thanks @dhowe for making the proposal. To better organize the proposals, could you add a title to this issue? Thanks. |
Increasing access
This allows users to access a fuller set of options for rendering to the canvas
Which types of changes would be made?
Most appropriate sub-area of p5.js?
What's the problem?
Current renderers do not give access to the full feature set for rendering to the canvas, specifically (for the '2d 'context) the following options:
alpha
A boolean value that indicates if the canvas contains an alpha channel. If set to false, the browser now knows that the backdrop is always opaque, which can speed up drawing of transparent content and images.
colorSpace Optional
Specifies the color space of the rendering context. Possible values are:
desynchronized
A boolean value that hints the user agent to reduce the latency by desynchronizing the canvas paint cycle from the event loop
willReadFrequently
A boolean value that indicates whether or not a lot of read-back operations are planned. This will force the use of a software (instead of hardware accelerated) 2D canvas and can save memory when calling getImageData() frequently.
There is a still larger set for the WebGL context here
What's the solution?
Allow an object holding
canvasContext
options to be passed intocreateCanvas
, as an optional parameter. When these are passed to the Renderer's constructor they can be used in thecanvas.getContext()
call. This is relatively simple to implement in the current code base and would cause no compatibility issues.Pros (updated based on community comments)
Example list:
Cons (updated based on community comments)
None
Proposal status
Under review
The text was updated successfully, but these errors were encountered: