 /* Given "value" and "max", the maximum value which we expect "value"
    to take, this returns an integer between 0 and 255 proportional to
    "value" divided by "max". */
+__device__
 int rgb_value(int value, int max) {
   return (int)(256 * (value / (double)max));
 }
 
+__device__
 int iteration(complex<double> c, int limit = 1000) {
   int i = 0;
   double n;

  return i;
}

int main() {
  Bitmap fruit;
  fruit.width = 5000;
  fruit.height = 5000;
  fruit.pixels = new Pixel[fruit.width * fruit.height];

  double lower = -2, upper = 2;
  for (int y = 0; y < fruit.height; ++y) {
    for (int x = 0; x < fruit.width; ++x) {
      complex<double> t(lower + (upper - lower) * x / (fruit.width - 1),
                        lower + (upper - lower) * y / (fruit.height - 1));
      int iter = iteration(t);
      Pixel* pixel = pixel_at(&fruit, x, y);
      pixel->red = rgb_value(1000 - iter, 1000);
      pixel->green = rgb_value(500 - iter, 1000);
      pixel->blue = rgb_value(200 - iter, 1000);
    }
  }

  /* Write the image to a file 'fruit.png'. */
  save_png_to_file(&fruit, "fruit.png");

  delete[] fruit.pixels;

  return 0;
}


};

// Given "bitmap", this returns the pixel of bitmap at the point ("x", "y").
__host__ __device__
Pixel* pixel_at(Bitmap* bitmap, int x, int y) {
  return bitmap->pixels + bitmap->width * y + x;
}
