int wid = 600; int hei = 600; void setup() { size(wid, hei); background(0); smooth(); } void draw() { fractal(wid, color(random(0,15), random(0,10), random(0,12))); } void fractal(float Wid, color Col) { noStroke(); int MaxIterations = 100; double MinimumDistance = 4.0; float acorner = -2.0; float bcorner = -1.25; float side = 2.5; double Gap = side/Wid; for (int x = 0; x < Wid; x++) { for (int y = 0; y < Wid; y++) { color nColor; double Size = 0; int Iterations = 0; // Convert x, y Cartesian point to a complex number. double ComplexPoint_x = x * Gap + acorner; double ComplexPoint_y = y * Gap + bcorner; double Zero_x = 0.0; double Zero_y = 0.0; do { // Zero = Zero ^ 2 + ComplexPoint double Tmp = (Zero_x + Zero_x) * Zero_y + ComplexPoint_y; Zero_x = (Zero_x * Zero_x - Zero_y * Zero_y + ComplexPoint_x); Zero_y = Tmp; Size = Zero_x * Zero_x + Zero_y * Zero_y; } while (Size < MinimumDistance && ++Iterations < MaxIterations); double Distance = Size; if (Distance <= MinimumDistance) { nColor = color(0,0,0); } else { nColor = Iterations * Col; } fill(nColor); rect(x, y, 1, 1); //g.DrawRectangle(new Pen(ColorMap.crColors[nColor]), x, y, 1, 1); } } }