MandelUtil.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. void zoomCenter(const Real& scale);
  33. /*!
  34. * \brief zoom in around a specific point
  35. * \param x value between 0.0f and 1.0f
  36. * \param y value between 0.0f and 1.0f
  37. */
  38. void zoom(float scale, float x, float y);
  39. void zoom(const Real& scale, const Real& x, const Real& y);
  40. /*!
  41. * \brief returns a viewport where the whole mandelbrot set can be observed
  42. */
  43. static MandelViewport standardView(void);
  44. /*!
  45. * \brief returns a viewport with (0, 0) in the center
  46. */
  47. static MandelViewport centerView(void);
  48. inline Real right() const { return x + width; }
  49. inline Real bottom() const { return y + height; }
  50. };
  51. struct mnd::MandelInfo
  52. {
  53. /// viewport
  54. MandelViewport view;
  55. /// width of the bitmap to be generated
  56. long bWidth;
  57. /// height of the bitmap to be generated
  58. long bHeight;
  59. /// maximum iterations
  60. long maxIter;
  61. /// smooth coloring
  62. bool smooth;
  63. bool julia = false;
  64. Real juliaX;
  65. Real juliaY;
  66. };
  67. #endif // MANDEL_MANDELUTIL_H