Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

PGF (LaTeX) indeed has a "Mandelbrot set" shading parameter[1]. Note: this is calculated by the PDF renderer. PDF has function shading and I think one can abuse it enough to render the Mandelbrot set. It certainly looks different in different viewers.

[1] http://mirror.switch.ch/ftp/mirror/tex/graphics/pgf/base/doc... Page 696



I did it in PDF by manually writing a custom tint transformation function. I used a 16x16 image with grayscale values from 0 to 255 and split the values in nibbles in the function code (which is a limited subset of postscript without things such as control flow). This worked fine, though a 16x16 Mandelbrot isn't very interesting.

So I tried with a 256x256 image instead with 16bpp, but it turns out that most viewers doesn't give a fuck and rounds the values down to 8 bits of precision before they are handed to the tint function.


Nice experiment. Some time ago I bumped into a similar problem when I experimented with SVGs lighting functions. SVG supports Phong shading based on a bump map. AFAIK you have to pass the bump map as the alpha channel of an image. Firefox only uses 8 bits for the alpha channel so the sphere I designed had steps on it.

Also Firefox used the sRGB non-linear colorspace for Phong shading producing incorrect results, but it was a different annoyance.


I just found my experiments. Code for the 16x16 Mandelbrot here: https://gist.github.com/poizan42/71f38038e8d91f91f8b8

Experimentation with creating 256x256 Mandelbrot here: https://gist.github.com/poizan42/3054232ad7624602a7fa


My sphere experiment:

https://jsfiddle.net/qb3pjojv/

Apparently Chromium has the same problem as Firefox, however the image doesn't look like the same in the two browsers. The Firefox version is much darker mostly because of the usage of the incorrect colorspace for shading.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: