-
Notifications
You must be signed in to change notification settings - Fork 0
/
SDLComplexe.hpp
87 lines (49 loc) · 2.13 KB
/
SDLComplexe.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef SDLCOMPLEXE_HPP
#define SDLCOMPLEXE_HPP
#include "SDL_Screen.hpp"
#include "Complexe.hpp"
#include "LinkedList.cpp"
using namespace std;
class SDLComplexe : public SDL_Screen{
private:
// linked list to keep the complex numbers
std::vector<Complexe> cList;
std::vector<double> divergence;
// zoom level, ie, the separation between two graduations
double zoom;
// center of the screen, if (0 ; 0), the screen will be centered on th origin of the axis
double center_x, center_y;
// number of graduations between a border of the screen and the origin
unsigned int graduation_count = 5;
int unit_cx = int(W() / (graduation_count*2 + 2));
int unit_cy = int(H() / (graduation_count*2 + 2));
// boolean variable indicating whether or not display the axis and graduations
bool display_axis = true;
// coordinates and previous coordinates of the mouse
int mouseX = 0, mouseY = 0, pmouseX = 0, pmouseY = 0;
// indicates whether or not the mouse is pressed
bool click = false;
TTF_Font *font;
int it_max = 2550; // max amount of iterations when computing mandelbrot
public:
SDLComplexe();
static void run();
/// @brief draw center point + lines
void draw_center();
void events() override;
void drawAxis();
void addComplexe(const Complexe c);
void addComplexe(const double re, const double im);
void addComplexe(const double re);
void displayComplexes();
void axis_button();
void load_mandelbrot(double min_x, double min_y, double max_x, double max_y, double precision);
void complexe_to_pixel(Complexe c, double *x, double *y);
void pixel_to_complexe(double x, double y, Complexe *c);
void pixel_to_complexe(double x, double y, double *Re, double *Im);
int compute_mandelbrot(Complexe c);
void center_on(double x, double y);
/// @brief prints the complexe coordinates of the center
void get_center(double*x, double*y);
};
#endif