Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getCanvasImage(_ctx, _bgColor){
- var tmpCtx = document.createElement("canvas").getContext("2d");
- tmpCtx.canvas.width = _ctx.canvas.width;
- tmpCtx.canvas.height = _ctx.canvas.height;
- tmpCtx.fillStyle = _bgColor;
- tmpCtx.fillRect(0, 0, tmpCtx.canvas.width, tmpCtx.canvas.height);
- tmpCtx.drawImage(_ctx.canvas, 0, 0);
- return tmpCtx.canvas;
- }
- // ...
- // just call the function passing your canvas context and the background color
- var graphImage = getCanvasImage(ctx, "#222");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement