4 examples/shootout/mandelbrot.pir - Print the Mandelbrot set
8 % ./parrot examples/shootout/mandelbrot.pir -j 600 > out.pbm
12 This outputs a pbm file of the Mandelbrot set. Defaults to 200x200.
14 Translated from C code by Greg Buchholz into PIR
15 by Peter Baylies <pbaylies@gmail.com>.
18 The Great Computer Language Shootout
19 http://shootout.alioth.debian.org/
25 # int w, h, x, y, bit_num = 0;
29 # double Zr, Zi, Cr, Ci, Tr, Ti;
30 .local int w, h, x, y, bit_num, byte_acc, i, iter
31 .local num limit, Zr, Zi, Cr, Ci, Tr, Ti
37 # slight optimization here -- nothing a decent C compiler wouldn't already do :)
41 if argc <= 1 goto noarg
47 # printf("P4\n%d %d\n",w,h);
60 # Cr = (2*(double)x/w - 1.5);
65 # Ci=(2*(double)y/h - 1);
73 # Tr = Zr*Zr - Zi*Zi + Cr;
86 # if (Zr*Zr+Zi*Zi > limit*limit) break;
90 if $N1 > limit goto IBRK
92 if i < iter goto IREDO
95 if $N1 <= limit goto SLA
100 if bit_num != 8 goto NTST1
101 PRINT: chr $S1, byte_acc
109 if x != $I1 goto NTSTE
128 # vim: expandtab shiftwidth=4: