Canvas API is slow by nature, don’t try to argue this, it is…
When using HTMLcanvas, we have to know how the whole thing works, first of all, the canvas 2D context itself is an Int8Array with length (side^2) * 4 and an API to modify this array, this API is an abstraction layer that allows you to easily draw shapes, paths, etc without leading with pixel modification or rasterizing.
Each time you tells this API to draw a rectangle, it calculates the new state of all the pixels involved, this could be easy, but if you draw a shape like an triangle or a irregular one, the API will triangulate it, calculate the pixels state and rasterize it, and trust me, this take’s a lot of time and hard working.
Continue reading “High performance with canvas prerendering”