MandelUtil.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef MANDEL_MANDELUTIL_H
  2. #define MANDEL_MANDELUTIL_H
  3. namespace mnd
  4. {
  5. struct MandelViewport;
  6. struct MandelInfo;
  7. }
  8. struct mnd::MandelViewport
  9. {
  10. /// real part of the top left corner
  11. double x = -2.1;
  12. /// imaginary part of the top left corner
  13. double y = -1.5;
  14. /// real-part span of the picture to be generated
  15. double width = 3;
  16. /// imaginary-part span of the picture to be generated
  17. double height = 3;
  18. /*!
  19. * \brief adjusts the aspect ratio of the viewport, making sure
  20. * the updated viewport contains all of the original one.
  21. */
  22. void adjustAspectRatio(double nwidth, double nheight);
  23. /*!
  24. * \brief make sure width and height are positive
  25. */
  26. void normalize(void);
  27. /*!
  28. * \brief zoom in around the center by a factor specified
  29. */
  30. void zoomCenter(float scale);
  31. /*!
  32. * \brief zoom in around a specific point
  33. * \param x value between 0.0f and 1.0f
  34. * \param y value between 0.0f and 1.0f
  35. */
  36. void zoom(float scale, float x, float y);
  37. /*!
  38. * \brief returns a viewport where the whole mandelbrot set can be observed
  39. */
  40. static MandelViewport standardView(void);
  41. inline double right() const { return x + width; }
  42. inline double bottom() const { return y + height; }
  43. };
  44. struct mnd::MandelInfo
  45. {
  46. /// viewport
  47. MandelViewport view;
  48. /// width of the bitmap to be generated
  49. long bWidth;
  50. /// height of the bitmap to be generated
  51. long bHeight;
  52. /// maximum iterations
  53. int maxIter;
  54. };
  55. #endif // MANDEL_MANDELUTIL_H