MandelbrotImage.h 1.0 KB

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