I am attempting to improve the draw speed of this JS heatmap library:
http://www.patrick-wied.at/static/heatmapjs/
With a view to getting animation to work. An abridged version of how it works- it draws all the data points (on a <canvas> that is never inserted into the DOM) as circles- all the same radius, but with varying alphas:
ctx.shadowColor = ('rgba(255,0,0,'+((count)?(count/me.store.max):'0.1')+')');
ctx.beginPath();
ctx.arc(x - 1000, y - 1000, radius, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fill();
Once they're all drawn, it runs getImageData() on that canvas, colorizing each pixel according to alpha, and then putImageData()-ing it on the final <canvas> that's present on the page.
Not surprisingly, the most intensive part of that operation is the drawing part. I'd love to be able to delegate that responsibility to a web worker, so that I could render future frames in advance without affecting the FPS in the browser. But web workers do not have DOM access, and cannot create <canvas> tags. Does anyone have any great ideas on ways around this? Is there any way that I can calculate these pixel alphas without a canvas tag?