-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmandelbrot.hpp
114 lines (80 loc) · 2 KB
/
mandelbrot.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//
// mandelbrot.hpp
// mandelbrot
//
// Created by Blake Johnson on 8/18/19.
// Copyright © 2019 Blake Johnson. All rights reserved.
//
#ifndef mandelbrot_hpp
#define mandelbrot_hpp
#include <stdio.h>
#include <SFML/Graphics.hpp>
#include <thread>
#include <fstream>
typedef double LD;
//typedef double LD;
extern int pixels [400][600];
extern sf::VertexArray vertexPixels;
struct panDir {
int x;
int y;
};
enum pan_dir{
left,
up,
right,
down
};
extern panDir pan[4];
class mandelbrot {
private:
int width;
int height;
LD man_Wid;
LD man_Height;
LD centerX;
LD centerY;
LD offsetX;
LD offsetY;
LD zoom;
LD zoomScalar;
int max_iteration;
int pixelCount;
std::thread th;
bool finished;
std::ofstream stream;
public:
mandelbrot();
~mandelbrot() {th.join();}
mandelbrot(int width, int height, int max_iteration, int zoomScalar);
void zoomIn(int x, int y);
void zoomOut();
void zoomToTop();
void panImg(pan_dir dir);
void loop();
void calculatePixel (int x, int y);
void setColor(int x, int y, int iterations);
LD picToMand_x (double x);
LD picToMand_y (double y);
bool isFinished ();
};
inline LD mandelbrot::picToMand_x(double x) {
return (x * (man_Wid / width)) + offsetX;
//return (x * ((0.7 + 1.5) / width)) - 1.5;
// return ((x * 3.5)/600) - 2.5;
// return (x - (width/2)) /float(300);
//return x * (1/120) +2.5;
}
inline LD mandelbrot::picToMand_y (double y){
//we use a -y value because the window y axis and mandelbrot y axis are reversed
return (-y * (man_Height/ height)) + offsetY;
//return -((2* y)/height) + 1;
// return (y * ((1 + 1) / height)) -1 ;
// return ((y * 3.5)/400) - 2.5;
// return (y - (height/2)) / float(300);
//return -(y/80) - 2.5;
}
inline bool mandelbrot::isFinished(){
return finished;
}
#endif /* mandelbrot_hpp */