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]);
      }
    }
  }
 private void ift(Complex[] F, byte[] img, int width, int height) {
   for (int x = 0; x < height; x++) {
     for (int y = 0; y < width; y++) {
       Complex c = new Complex();
       for (int u = 0; u < height; u++) {
         for (int v = 0; v < width; v++) {
           Complex tmp =
               Complex.fromPolar(
                   1, 2.0 * Math.PI * (u * x / (double) height + v * y / (double) width));
           c = c.plus(tmp.mul(F[u * width + v]));
         }
       }
       c = c.div(height * width);
       c = c.mul(Math.pow(-1, (x + y)));
       if (c.getReal() < 0) c.setReal(0.0);
       System.out.println(c.getReal());
       img[x * width + y] = (byte) (c.getReal());
     }
   }
 }