1 // This may look like C code, but it's really -*- C++ -*- 2 /* 3 * Copyright (C) 2008 Emweb bv, Herent, Belgium. 4 * 5 * See the LICENSE file for terms of use. 6 */ 7 8 #ifndef MANDELBROT_IMAGE_H_ 9 #define MANDELBROT_IMAGE_H_ 10 11 #include <Wt/WVirtualImage.h> 12 13 using namespace Wt; 14 15 namespace Wt { 16 class WRasterImage; 17 } 18 19 class MandelbrotImage : public WVirtualImage 20 { 21 public: 22 MandelbrotImage(int width, int height, 23 int64_t virtualWidth, int64_t virtualHeight, 24 double bx1, double by1, 25 double bx2, double by2); 26 27 void zoomIn(); 28 void zoomOut(); 29 30 void generate(int64_t x, int64_t y, WRasterImage *img); 31 32 double currentX1() const; 33 double currentY1() const; 34 double currentX2() const; 35 double currentY2() const; 36 37 private: 38 double bx1_, by1_, bwidth_, bheight_; 39 int maxDepth_; 40 double bailOut2_; 41 42 virtual std::unique_ptr<WResource> render(int64_t x, int64_t y, int w, int h); 43 double calcPixel(double x, double y); 44 45 double convertPixelX(int64_t x) const; 46 double convertPixelY(int64_t y) const; 47 }; 48 49 #endif // MANDELBROT_IMAGE_H_ 50