williamngan / pts

A library for visualization and creative-coding
https://ptsjs.org
Apache License 2.0
5.17k stars 182 forks source link

Implement a download function #165

Open williamngan opened 2 years ago

HenrySkup commented 2 years ago

I've done some work in trying to implement this. There are some complications due to some security issues of downloading embedded objects (I believe canvases which are in svgs may not be automatically inserted), and text/DOM and particularly <foreignObjects> elements may give issues.

see: https://observablehq.com/@mbostock/saving-svg and : https://observablehq.com/@mootari/embed-canvas-into-svg and : https://stackoverflow.com/questions/39148582/javascript-todataurl-throwing-security-error-tainted-canvases-may-not-be-ex/39150005

williamngan commented 2 years ago

Interesting. Thanks for the great info @HenrySkup . I'm reopening this issue so that we don't lose track of this.