3 ms·
I appreciate your detail here and I think I agree with some of your points. What is the source of your PoV on Canvas, though? From my history of using it and th
by kevingadd 13y ago
I appreciate your detail here and I think I agree with some of your points. What is the source of your PoV on Canvas, though? From my history of using it and the other end users I've interacted with who use Canvas, I just don't understand how someone could call it 'extremely well thought through' as an API.
Canvas literally prioritized narrow support for things like drop shadows over support for basic, established rendering essentials like blending operations, well-specified clipping/sampling semantics, control over scaling, and basic image data filtering/transformation. Many of the obvious features Canvas is missing have been in SVG for years now, and have been in applications like Photoshop and in most game-oriented rendering libraries for decades. This is fine in an early vendor-driven prototype but the fact remains that even now many of those things I described are still not possible with Canvas, and Apple has no excuse: They needed only look at things real software did in rendering.
Canvas also remains an incredibly slow API by specification, not just due to poor luck of aligning badly with the GPU: The bread and butter drawImage operation is itself specified in a way that makes it considerably more expensive to implement (for general cases) than it needs to be, and I can only blame this on Apple's PoV on rendering at the time infecting the design of the spec. There are other design decisions that unnecessarily cripple its use for image rendering and image processing; the need to render an image to a canvas and read it back just to get at pixel data is a big problem that is only now being addressed thanks to the valiant efforts of the WhatWG. Canvas's incredibly poor performance also undermines any attempt to claim that Apple might have left key features out 'to make it fast'. I will note that most browser vendors have gone to valiant efforts here to make Canvas fast, and they've done a good job - but it still performs terribly.
The Canvas API also has severe underspecification/poor specification problems when it comes to image quality concerns; its treatment of sampling/filtering (in particular when dealing with subrectangles) and its handling of color profiles/gamma are both hopelessly underspecified to the point that it is no longer possible to fix either of them without breaking applications that have accidentally relied on the arbitrary behavior of existing implementations.
HTML5 Canvas is unfit for: Realtime rendering scenarios, offline rendering scenarios, and 'real' image processing/editing scenarios, among others.