mandelbrotGraphics.frink

View or download mandelbrotGraphics.frink in plain text format

/** This is a very simple demonstration program that shows the basics of
    calculating the Mandelbrot set and displaying it as graphics. */


// Maximum levels for each pixel.
levels = 30

// Create a random color for each level.
colors = new array[[levels]]
for a = 0 to levels-1
   colors@a = new color[randomFloat[0,1], randomFloat[0,1], randomFloat[0,1]]

// Make this number smaller for higher resolution.
stepsize = .01

g = new graphics
for im = -1.2 to 1.2 step stepsize
{
   imag = i * im
   for real = -2 to 1 step stepsize
   {  
      C = real + imag
      z = 0
      count = -1

      do
      {
         z = z^2 + C
         count=count+1;
      } while abs[z] < 4 and count < levels

      g.color[colors@(count-1)]
      g.fillRectSize[real, im, stepsize, stepsize]
   }
}

g.show[]


View or download mandelbrotGraphics.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 17596 days, 22 hours, 5 minutes ago.