1 # Copyright (C) 2005-2008, The Perl Foundation.
6 examples/pir/mandel.pir - Print the Mandelbrot set
10 % ./parrot examples/pir/mandel.pir
14 This prints an ASCII-art representation of the Mandelbrot set.
16 Translated from C code by Glenn Rhoads into Parrot assembler
17 by Leon Brocard <acme@astray.com>.
18 Translated from PASM to PIR by Bernhard Schmalhofer.
24 char *b = " .:,;!/>)|&IH%*#";
25 float r, i, z, Z, t, c, C;
26 for (y=30; puts(""), C = y*0.1 - 1.5, y--;) {
27 for (x=0; c = x*0.04 - 2, z=0, Z=0, x++ < 75;) {
28 for (r=c, i=C, k=0; t = z*z - Z*Z + r, Z = 2*z*Z + i, z=t, k<112; k++)
29 if (z*z + Z*Z > 10) break;
30 printf ("%c", b[k%16]);
41 .local num r, i, z, Z, t, c, C
43 b = " .:,;!/>)|&IH%*#"
46 YREDO: # C = y*0.1 - 1.5
52 XREDO: # c = x*0.04 - 2
63 KREDO: # t = z*z - Z*Z + r
77 # if (z*z + Z*Z > 10) break;
81 if $N1 > 10 goto PRINT
87 $S1 = substr b, $I1, 1
102 # vim: expandtab shiftwidth=4 ft=pir: