node.js - node-o3-canvas vs. node-canvas? -


does have experience either or both of these node.js libraries? curious hear success or difficulties each one.

learnboost 1 of prolific node module developers in community , reason went node-canvas on node-o3-canvas.

i used node-canvas slice image tiles on server , send them client. works expect. here sample of kind of code might write:

helper = function(x, y, canvas) {     return function(err, str) {         if (!tiles[x]) {             tiles[x] = [];         }          tiles[x][y] = {              data: str             , buffer: canvas.tobuffer()             , covered: true          };     }; };    (y = 0; y < tilespercolumn; y += 1) {     (x = 0; x < tilesperrow; x += 1) {         //create new tile canvas each time don't run on each other         tcanvas = new canvas(chunksize, chunksize);         tctx = tcanvas.getcontext('2d');          xoffset = chunksize * x;         yoffset = chunksize * y;          //save set of uncovered tiles store in memory         tctx.drawimage(img, xoffset, yoffset, chunksize, chunksize, 0, 0, chunksize, chunksize);         tcanvas.todataurl(helper(x, y, tcanvas));             } } 

the gotchas had were:

  • if using async methods in node-canvas, need careful allocate new canvas/context instances not interrupt 1 may writing/drawing.
  • for reason, never able node-canvas's image() object work correctly when using server-side base64 encoded images. issue onload event not fire when src property assigned base64 string. didn't spend time fighting this, , instead wrote images out temporary files work around problem.

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -