html - Fastest way to create a JSON serializable image in node.js & place it on client canvas? -
i'm building app meteor.js requires dynamically generated images. whole lot of small, dynamically generated images; generated pixel pixel, collectively require ~25000 pixels of image per second. realizing quite computational load, i've decided use meteor's server methods speed process.
as of now, here's functional attempt:
server-side generation of pixel array
loadimage = function(){ this.imagepixels = new uint8array(4*dim*dim); for(var = 0; < dim; i++){ for(var j = 0; j < dim; j++){ var x = 255*i/dim; var y = 255*j/dim; this.setpixel(this.imagepixels, i, j, eval(this.redeq) , eval(this.greeneq) , eval(this.blueeq) , 255); } } }
and intermediate stuff happens (code not shown), data sent client, , following places "image" onto canvas via uint8array.set:
var elem = document.getelementbyid(this.canvasid); var ctx = elem.getcontext('2d'); var imagedata = ctx.getimagedata(0, 0, dim, dim); var data = imagedata.data; data.set(this.evo.pixels); ctx.putimagedata(imagedata, 0, 0);
this fine , dandy except... need speed. so, being said, here's question:
is possible create json serializable image within node.js can efficiently placed on html canvas and, if so, how?
Comments
Post a Comment