DECLARE STRUCTURE struct2: 2 OF NUMERIC
DECLARE MESSAGE buff OF struct2

PARACT part1
OPTION ARITHMETIC complex
DECLARE NUMERIC left,right,h
START part2
LET left = -2
LET right= .8                             
LET h = (right - left) 
SET WINDOW left, right,-h/2,h/2  
DRAW axes  
SET POINT STYLE 1
DECLARE NUMERIC px,py
ASK PIXEL SIZE(left,-h/2;right,h/2) px,py
SEND TO buff FROM px,py
DECLARE EXTERNAL SUB mandelb
call mandelb(0,int(px/2),int(py/2),py)
END PARACT

PARACT part2
OPTION ARITHMETIC complex
DECLARE NUMERIC px,py
RECEIVE FROM buff TO px,py
DECLARE EXTERNAL SUB mandelb
CALL mandelb(INT(px/2)+1,px,INT(py/2),py)
END PARACT

EXTERNAL SUB mandelb(a0,a1,b0,b1)
OPTION ARITHMETIC complex
DECLARE NUMERIC i,mu,z
DECLARE NUMERIC a,b,u,v
DECLARE NUMERIC n
LET i=sqr(-1)
FOR a=a0 TO a1
   LET u=problemx(a)
   FOR b=b0 TO b1
      LET v=problemy(b)
      LET mu=u+v*i
      LET z=0
      FOR n = 1 TO 250
         LET z=z^2+mu
         IF abs(z)>4 THEN EXIT FOR
      NEXT n
      IF n>250 THEN
         PLOT POINTS: u,v
         PLOT POINTS: u,-v
      END IF
   NEXT b
NEXT a                                        
END SUB


