Closed alx5962 closed 10 years ago
Sorry, but this method of generating PNGs is broken cross-browser (Safari security policies taint the canvas so the canvas.toDataURL call will fail, and the noise filter will crash Chrome and Firefox when attempting to convert a canvas to PNG).
Closing as a duplicate of #11, #6, #1.
I agree about the canvas.toDataURL, even if Safari is a only a small percent of web browsers (BTW SVG is not well supported too on all browsers: http://caniuse.com/#feat=svg).
Noise filter doesn't crash the browser, it was just taking some time to render. I made it 3 times faster in the latest update(check my repository); Now, it only takes 1.5s to generate it with noise.
Just FYI, rasterizing an SVG with an feTurbulence fractalNoise effect via canvas does crash chrome/FF (or at least it did last time I checked).
Unfortunately, while it's faster replacing the fractal noise with random rectangles is not really a viable alternative to a true fractal or gaussian noise generator - rectangular random noise tends to look like kinda ugly JPEG artifacts, whereas true fractal or gaussian noise is pretty different looking and is the standard noise generation algorithm used for most graphical applications.
Thanks for taking the time to send a PR, but unfortunately the browser support just isn't there yet for PNG generation in the browser to be a viable option.
Export to PNG is supported now, just add to options: format:"png". It's faster to generate using PNG and have a better compatibility with mobile browsers.