Advertisement
cartagenae

ComplexPlane.h

Apr 25th, 2025
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <SFML/Graphics.hpp>
  2. #include <SFML/Audio.hpp>
  3. #include <iostream>
  4. #include <sstream>
  5. #include <vector>
  6. #include <complex>
  7.  
  8. using namespace std;
  9. using namespace sf;
  10.  
  11. const unsigned int MAX_ITER = 64;
  12. const float BASE_WIDTH = 4.0;
  13. const float BASE_HEIGHT = 4.0;
  14. const float BASE_ZOOM = 0.5;
  15.  
  16. enum class State
  17. {
  18.     CALCULATING,
  19.     DISPLAYING
  20. };
  21.  
  22. class ComplexPlane : public sf::Drawable
  23. {
  24. private:
  25.     VertexArray m_vArray;
  26.     State m_state;
  27.     Vector2f m_mouseLocation;
  28.     Vector2i m_pixel_size;
  29.     Vector2f m_plane_center;
  30.     Vector2f m_plane_size;
  31.     int m_zoom_count;
  32.     float m_aspectRatio;
  33.  
  34.     ComplexPlane(int pixelWidth, int pixelHeight);
  35.  
  36.     void draw(RenderTarget& target, RenderStates states) const;
  37.  
  38.     void updateRender();
  39.  
  40.     void zoomIn();
  41.  
  42.     void zoomOut();
  43.  
  44.     void setCenter(Vector2i mousePixel);
  45.  
  46.     void setMouseLocation(Vector2i mousePixel);
  47.  
  48.     void loadText(Text& text);
  49.  
  50.     size_t countIterations(Vector2f coord);
  51.  
  52.     void iterationsToRGB(size_t count, Uint8& r, Uint8& g, Uint8& b);
  53.  
  54.     Vector2f mapPixelToCoords(Vector2i mousePixel);
  55. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement