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 .




for y0 range 300
  cy = (y0 - 150) / 120
  for x0 range 300
    cx = (x0 - 220) / 120
    x = 0
    y = 0
    color3 0 0 0
    for n range 128
      if x * x + y * y > 4
        color3 n / 16 0 0
        break 1
      .
      h = x * x - y * y + cx
      y = 2 * x * y + cy
      x = h
    .
    move x0 / 3 y0 / 3
    rect 0.4 0.4
  .
.