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 .




DEFINE VARIABLE print_str AS CHAR NO-UNDO INIT ''.
DEFINE VARIABLE X1 AS DECIMAL NO-UNDO INIT 50.
DEFINE VARIABLE Y1 AS DECIMAL NO-UNDO INIT 21.
DEFINE VARIABLE X AS DECIMAL NO-UNDO.
DEFINE VARIABLE Y AS DECIMAL NO-UNDO.
DEFINE VARIABLE N AS DECIMAL NO-UNDO.
DEFINE VARIABLE I3 AS DECIMAL NO-UNDO.
DEFINE VARIABLE R3 AS DECIMAL NO-UNDO.
DEFINE VARIABLE Z1 AS DECIMAL NO-UNDO.
DEFINE VARIABLE Z2 AS DECIMAL NO-UNDO.
DEFINE VARIABLE A AS DECIMAL NO-UNDO.
DEFINE VARIABLE B AS DECIMAL NO-UNDO.
DEFINE VARIABLE I1 AS DECIMAL NO-UNDO INIT -1.0.
DEFINE VARIABLE I2 AS DECIMAL NO-UNDO INIT 1.0.
DEFINE VARIABLE R1 AS DECIMAL NO-UNDO INIT -2.0.
DEFINE VARIABLE R2 AS DECIMAL NO-UNDO INIT 1.0.
DEFINE VARIABLE S1 AS DECIMAL NO-UNDO.
DEFINE VARIABLE S2 AS DECIMAL NO-UNDO.
 
 
S1 = (R2 - R1) / X1.
S2 = (I2 - I1) / Y1.
DO Y = 0 TO Y1 - 1:
  I3 = I1 + S2 * Y.
  DO X = 0 TO X1 - 1:
    R3 = R1 + S1 * X.
    Z1 = R3.
    Z2 = I3.
    DO N = 0 TO 29:
      A = Z1 * Z1.
      B = Z2 * Z2.
      IF A + B > 4.0 THEN
        LEAVE.
      Z2 = 2 * Z1 * Z2 + I3.
      Z1 = A - B + R3.
    END.
    print_str = print_str + CHR(62 - N).
  END.
  print_str = print_str + '~n'.
END.
 
OUTPUT TO "C:\Temp\out.txt".
MESSAGE print_str.
OUTPUT CLOSE.
 