MandelUtil.h 1.6 KB

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