qrohlf / trianglify

Algorithmically generated triangle art
http://qrohlf.com/trianglify/
GNU General Public License v3.0
10.08k stars 669 forks source link

PNG support #15

Closed alx5962 closed 10 years ago

alx5962 commented 10 years ago

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.

qrohlf commented 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.

alx5962 commented 10 years ago

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.

qrohlf commented 10 years ago

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.