Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

document.createElement

1465699744
Pyromanci
Sheet Author
API Scripter
I'm currently trying to make a canvas from the api copy the background layer to it and then save it off as a single image. A couple maps i've done are very very large and take a fair bit of time to load.  The code it's self is simple enough, but i noticed that document.createElement(); give's an error were document is not defined. So how else can I do this?
1465711335

Edited 1465711364
Lithl
Pro
Sheet Author
API Scripter
document  is a variable defined for client-side JavaScript environments. API scripts run on the server (think NodeJS), and as such you will never have a document object. The API also has no access to the various interfaces used by the Canvas API, so you would not even be able to construct an image in-memory with an OffscreenCanvas object. Finally, since the API runs on the server, there is no means by which you could save any such image to your computer, even if you were to generate it somehow. The best you could possibly do is generate an SVG as text, and copy that text into an SVG file.
1465712216
Pyromanci
Sheet Author
API Scripter
That is what I thought. Which is some what regrettable. Thank you.