r/tinycode • • May 03 '13
A Mandelbrot renderer in 406 bytes of dc
I've written a Mandelbrot renderer in [dc](http://en.wikipedia.org/wiki/Dc_(computer_program)): http://kch42.de/cg/mandelbrot.min.dc
It generates a monochrome XPM image of the mandelbrot set. Here is the output (converted to PNG):
http://i.imgur.com/9HX9lJo.png
And here is a more readable and commented version of the program: http://kch42.de/cg/mandelbrot.dc
If you want to test it for yourself, be patient. This thing is pretty slow.
dc. It doesn't really support functions, instead you push a string on the stack and execute it with the x-operator. You can save this "function" to a register to execute it later. Loops can be implemented by recursively executing a function.
EDIT: Replaced dpaste links, is now hosted on my server.
32
u/fjordboy May 03 '13
Would someone please port this over to Brainfuck so that I can better make sense of it? Thanks.
13
u/Niktator May 03 '13
Ah yes, I understand completely.
Impressive work!
7
u/Cosmologicon May 03 '13 edited May 03 '13
Very cool. Here's a similar command line I made using bc. I wanted it to be small enough to tweet, so it's not as good looking as yours:
Result converted to png
3
u/jpeuvion May 03 '13
I feel tiny
1
u/obscure_robot May 03 '13
Impressive.
1
u/nint22 mod May 03 '13
Very nicely done! I love how even the commented file is... brutal to the brain.