Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. function getCanvasImage(_ctx, _bgColor){
  2. var tmpCtx = document.createElement("canvas").getContext("2d");
  3. tmpCtx.canvas.width = _ctx.canvas.width;
  4. tmpCtx.canvas.height = _ctx.canvas.height;
  5. tmpCtx.fillStyle = _bgColor;
  6. tmpCtx.fillRect(0, 0, tmpCtx.canvas.width, tmpCtx.canvas.height);
  7. tmpCtx.drawImage(_ctx.canvas, 0, 0);
  8.  
  9. return tmpCtx.canvas;
  10. }
  11.  
  12. // ...
  13. // just call the function passing your canvas context and the background color
  14. var graphImage = getCanvasImage(ctx, "#222");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement