The simplest algorithm for generating a representation of the Mandelbrot set is known as the escape time algorithm. A repeating calculation is performed for each x, y point in the plot area and based on the behavior of that calculation, a color is chosen for that pixel.
The x and y locations of each point are used as starting values in a repeating, or iterating process of calculations. The result of the previous iteration defines the starting values for the next iteration. The result of the previous iteration is also checked during the next iteration to see if a critical escape condition or bailout has been reached. If and when that condition is reached, the calculation is stopped, the pixel is drawn, and the next x, y point is examined. For some starting values, escape occurs quickly, after only a small number of iterations. For starting values very close to but not in the set, it may take hundreds or thousands of iterations to escape. For values within the Mandelbrot set, escape will never occur. The higher the maximum number of iterations, the more detail and subtlety emerge in the final image, but the longer time it will take to calculate the fractal image.
Escape conditions can be simple or complex. Because no complex number with a real or imaginary part greater than 2 can be part of the set, a common bailout is to escape when either coefficient exceeds 2. A more computationally complex method, but which detects escapes sooner, is to compute the distance from the origin using the Pythagorean Theorem, and if this distance exceeds two, the point has reached escape. More computationally-intensive rendering variations such as Buddhabrot detect an escape, then use values iterated along the way.
The color of each point represents how quickly the values reached the escape point. Often black is used to show values that fail to escape before the iteration limit, and gradually brighter colors are used for points that escape. This generates a visual representation of how many cycles were required before reaching the escape condition.