-
Notifications
You must be signed in to change notification settings - Fork 25
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
Proposals #19
Comments
Thank you so much for bringing those up. If you ever have other suggestions, please don't hesitate to bring them up. |
I think current proposals cover most use cases. Some yeas ago I reimplementes the whole Canvas2D context in WebGL for a project where I wanted to mix Canvas2D and WebGL seamesly without having to upload the whole canvas to the GPU every frame. The project can be found here: https://github.com/jagenjo/Canvas2DtoWebGL And while doing it I started experimenting with extra methods that I found necessary as the mentioned before. Thats why I want to bring them to regular Canvas2D. Most of them are in your proposal (like matrix4x4 as transform, roundRect or fillColor). Glad to help. |
We'll probably come back to this later, but a few notes:
|
My reply:
Thanks for taking the time to answer. |
Regarding the calls to |
If I think it would be nice if Additional possible directions for canvas would be
|
Just to give a little more context, the The idea of |
As far as I can tell by looking at this 21.4MB PDF specs, PDF path drawing commands are To make a parallel with the Canvas2D API, these would correspond to a CanvasGradient object. As I stated in #19 (comment) this indeed sounds like the best direction for this. I'm still not convinced that we need a new CanvasPath triangle primitive.
The WebCodecs APIs should handle this. For gif images there is the ImageDecoder, for videos the VideoDecoder one. |
I would argue that since gradient triangles and gradient textured triangles are the underlying primitive of a modern 2D graphics pipeline, it would make sense to expose them as fundamental operations in the API, and to make them performant too. If you make these operations only available through CanvasGradient, programmers will, essentially, draw a single big rectangle over the whole canvas and just draw everything using a big CanvasGradient that fills the rectangle. And it will be a mess because programmers will end up bypassing all the transforms and paths. It’s not clear if it will be performant either. If you look at the way gradient meshes are exposed in vector drawing tools, they are exposed as their own primitive, even though they are exported as Patterns in PDF documents. They are like text and images—they are their own thing separate from paths. |
I'm sorry I don't quite understand your arguments. Also, while I guess there will be a performant path with HWA, I can also imagine that some will complain that in CPU rendering shaders aren't accessible and that it could be very slow (but once again I'm not an implementer and may be wrong). |
Yes, I'm assuming that a proper performant API would allow programmers to send batches of thousands of triangles in one go, either that or the rendering context would batch up triangle operations itself. I'm arguing that in games and in modern gradient systems, all rendering is done with (textured) triangle primitives. In implementation, there probably isn't much difference between rendering triangles while clipping them to a path, or rendering triangles as a canvas gradient that fills a path. You could also argue that images and text should also be CanvasGradients because maybe a programmer wants to stroke a path using text and image patterns. The main issue is that I feel like the API designers won't give enough attention to the design of the API if they hide it in a CanvasGradient. Graphics engines will want to render everything except for text using these (textured) gradient triangles. It's important that these triangle APIs are designed carefully to support the use-case of all rendering going through them. They have to be sufficiently flexible and performant to support 2d games with skeletal animation of its sprites (like Esoteric Software's Spine) or vector drawing packages that where entire images are made up of Coons patches and diffusion curves. You could argue that those graphics engines should simply adopt WebGL instead, but then I would suggest that Canvas can't meet the needs of modern 2d graphics engines and that the future of Canvas is to make its functionality more accessible from WebGL and not to add new features. |
Here are some proposals with features I felt missing in the past:
Nice to have
The text was updated successfully, but these errors were encountered: