QueueManager.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "QueueManager.h"
  2. #include <cmath>
  3. void MandelViewport::adjustAspectRatio(double nwidth, double nheight)
  4. {
  5. double otherRatio = nwidth / nheight;
  6. if (width < height * otherRatio)
  7. width = height * otherRatio;
  8. else if (height < width / otherRatio)
  9. height = width / otherRatio;
  10. }
  11. void MandelViewport::normalize(void)
  12. {
  13. if (width < 0) {
  14. x += width;
  15. width = -width;
  16. }
  17. if (height < 0) {
  18. y += height;
  19. height = -height;
  20. }
  21. }
  22. MandelGenerator::~MandelGenerator(void)
  23. {
  24. }
  25. Bitmap<RGBColor> MandelGenerator::generate(const MandelInfo& mandelInfo)
  26. {
  27. auto converter = [max = mandelInfo.maxIter](float i) {
  28. return i >= max ?
  29. RGBColor{ 0,0,0 } :
  30. RGBColor{
  31. uint8_t(cos(i * 0.15f) * 127 + 127),
  32. uint8_t(sin(i * 0.03f) * 127 + 127),
  33. uint8_t(cos(i * 0.04f) * 127 + 127)
  34. };
  35. };
  36. return generateRaw(mandelInfo).map<RGBColor>(converter);
  37. }
  38. QueueManager::QueueManager()
  39. {
  40. }
  41. QueueManager::~QueueManager()
  42. {
  43. }