(* Copyright (C) 2000-2001 Samuel Thibault This program is free software : you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation ; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the program ; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This License should be available in the same directory as this program, in a file called COPYING. If not, you may ask the webmaster or ftpmaster *) let minx= -2. and maxx= 1. and miny= -1.25 and maxy= 1.25;; #open "graphics";; open_graph "";; let sizex=float_of_int (size_x ()) and sizey=float_of_int (size_y());; clear_graph();; let round x = if x >=. 0.0 then int_of_float(x +. 0.5) else -(int_of_float(0.5 -. x));; let carre (x,y)=(x*.x-.y*.y,2.*.x*.y);; let plus (x1,y1) (x2,y2)= (x1+.x2,y1+.y2);; let module (x,y)=sqrt (x*.x +. y*.y);; let pixel c = let z=ref (0.,0.) and N=ref 0 in while module !z <. 2. & !N<255 do incr N; z:=plus (carre !z) c done; let IzI=round(module !z) in if IzI <2 then black (* else white;;*) else rgb (255-!N*3/2) 0 0;; (* else !N mod 4+( !N / 4) mod 4 * 256 + (!N / 16) *65536;;*) let mandelbrot ()= let i=ref minx in while !i