Seriously.js icon indicating copy to clipboard operation
Seriously.js copied to clipboard

How to output the image to a canvas not attached to DOM?

Open windofsoltia opened this issue 9 years ago • 1 comments

If I set target like this

var target = seriously.target("#catcanvas");

it can output the right image in the web browser;

but if I use

var canvas = document.createElement("canvas"); var target = seriously.target(canvas); .... seriously.go();

var img = document.createElement("img"); img.src= canvas.toDataURL()

I got nothing!The image is blank!

how to fix it?

windofsoltia avatar Aug 09 '16 11:08 windofsoltia

This is not really directly related to Seriously.js, so a better place for these questions would be Stackoverflow (or just a quick google search).

Try adding a width and height to your canvas before using it:

var canvas = document.createElement("canvas");
canvas.width = 1280;
canvas.height = 720;

felipebrahm avatar Aug 09 '16 15:08 felipebrahm