Mandelbrot set: Difference between revisions

Content added Content deleted
m (→‎ASCII output: fix links)
Line 1,861: Line 1,861:
[[File:Mandelbrot-bc.jpg|thumb|right]]
[[File:Mandelbrot-bc.jpg|thumb|right]]
Producing a [https://fr.wikipedia.org/wiki/Portable_pixmap PGM] image.
Producing a [https://fr.wikipedia.org/wiki/Portable_pixmap PGM] image.

To work properly, this needs to run with the environment variable BC_LINE_LENGTH set to 0.

<syntaxhighlight lang=bc>max_iter = 50
<syntaxhighlight lang=bc>max_iter = 50
width =400; height=400
width = 400; height = 401
scale = 10
scale = 10
xmin = -2; xmax = 1/2
xmin = -2; xmax = 1/2
Line 1,891: Line 1,894:
print "P2\n", width, " ", height, "\n255\n"
print "P2\n", width, " ", height, "\n255\n"


for (i = 0; i < width; i++) {
for (i = 0; i < height; i++) {
x = xmin + (xmax - xmin) / width * i
y = ymin + (ymax - ymin) / height * i
for (j = 0; j < height; j++) {
for (j = 0; j < width; j++) {
y = ymin + (ymax - ymin) / height * j
x = xmin + (xmax - xmin) / width * j
tmp_scale = scale
tmp_scale = scale
scale = 0
scale = 0
m = (255 * mandelbrot(x, y) + max_iter + 1) / max_iter
m = (255 * mandelbrot(x, y) + max_iter + 1) / max_iter
print m
print m
if ( j < height - 1 ) print " "
if ( j < width - 1 ) print " "
scale = tmp_scale
scale = tmp_scale