public void ritaUt() { Complex z, hej; boolean isInside; int antalN = 0; background(0); for (int i = 0; i < width * height; i++) { isInside = true; z = toComplex(indexToPixel(i)[0], indexToPixel(i)[1]); for (int a = 0; a <= maxIterations; a++) { if ((z.getRe() * z.getRe() + z.getIm() * z.getIm()) > 4.0) { isInside = false; antalN = a; break; } hej = z.mul(z); z = hej.add(c); } if (isInside) { stroke(0); point(indexToPixel(i)[0], indexToPixel(i)[1]); } else { // the smmoth fade from black to red to yellow to white to yellow to black. if (antalN <= 12) { stroke(antalN * 21, 0, 0); } else if (antalN <= 24) { stroke(252, (antalN - 12) * 21, 0); } else if (antalN >= 76) { stroke(255 - (antalN - 76) * 7, 140 - (antalN - 76) * 8, 0); } else if (antalN >= 40) { stroke(252, 252 - (antalN - 40) * 4, 140 - (antalN - 40) * 9); } else { stroke(255 /*-((antalN-24)/6)*/, 252, (antalN - 24) * 9); } point(indexToPixel(i)[0], indexToPixel(i)[1]); } } }