I expect DOM to be very much slower - usually suggested to limit DOM manipulation.
Could try drawing a load of 1px by 1px squares. Maybe in a 100x100 Area. And benchmarking. Average 3 runs. Then further test - change colours of them all 1 by 1. Average 3 runs. Will write one on my side later if you'd like.
// imgData.data contains huge array with rgba values for each pixel
const imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
So for a 2 by 2px canvas imgData.data contains
imgData.data = [r, g, b, a,
r, g, b, a,
r, g, b, a,
r, g, b, a]
First pixel data lives at index 0-3 Second at 4-7 etc .
1
u/Volv May 18 '16
You can solve the odd fish sized cursor problem when you update the cursor
Codpen
div.style.top = e.y + "px";div.style.left = e.x + "px";document.body.style.cursor = "url('http://i63.tinypic.com/2cgbitt_th.jpg') 70 120, default";