Mandelbrot set

You are encouraged to solve this task according to the task description, using any language you may know.


Task

Generate and draw the Mandelbrot set.



Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .




include "cowgol.coh";
 
const xmin := -8601;
const xmax := 2867;
const ymin := -4915;
const ymax := 4915;
const maxiter := 32;
 
const dx := (xmax-xmin)/79;
const dy := (ymax-ymin)/24;
 
var cy: int16 := ymin;
while cy <= ymax loop
    var cx: int16 := xmin;
    while cx <= xmax loop
        var x: int32 := 0;
        var y: int32 := 0;
        var x2: int32 := 0;
        var y2: int32 := 0;
        var iter: uint8 := 0;
 
        while iter < maxiter and x2 + y2 <= 16384 loop
            y := ((x*y)>>11)+cy as int32;
            x := x2-y2+cx as int32;
            x2 := (x*x)>>12;
            y2 := (y*y)>>12;
            iter := iter + 1;
        end loop;
 
        print_char(' ' + iter);
        cx := cx + dx;
    end loop;
    print_nl();
    cy := cy + dy;
end loop;