Skip to content

Commit db98e56

Browse files
committed
.
1 parent 406353f commit db98e56

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed

Advanced-Cpp-Programming.vcxproj

+2
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,14 @@
137137
<ClInclude Include="Cpp%2711 New features\Ring.h" />
138138
<ClInclude Include="Template Classes and Functions\Template-class.h" />
139139
<ClInclude Include="Fractal Images\Zoom.h" />
140+
<ClInclude Include="Fractal Images\ZoomList.h" />
140141
</ItemGroup>
141142
<ItemGroup>
142143
<ClCompile Include="Fractal Images\Bitmap.cpp" />
143144
<ClCompile Include="Fractal Images\main.cpp" />
144145
<ClCompile Include="Fractal Images\Mandelbrot.cpp" />
145146
<ClCompile Include="Operator Overloading\Complex.cpp" />
147+
<ClCompile Include="Fractal Images\ZoomList.cpp" />
146148
</ItemGroup>
147149
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
148150
<ImportGroup Label="ExtensionTargets">

Advanced-Cpp-Programming.vcxproj.filters

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
<ClInclude Include="Fractal Images\Zoom.h">
4343
<Filter>Header Files</Filter>
4444
</ClInclude>
45+
<ClInclude Include="Fractal Images\ZoomList.h">
46+
<Filter>Header Files</Filter>
47+
</ClInclude>
4548
</ItemGroup>
4649
<ItemGroup>
4750
<ClCompile Include="Operator Overloading\Complex.cpp">
@@ -56,5 +59,8 @@
5659
<ClCompile Include="Fractal Images\Mandelbrot.cpp">
5760
<Filter>Source Files</Filter>
5861
</ClCompile>
62+
<ClCompile Include="Fractal Images\ZoomList.cpp">
63+
<Filter>Source Files</Filter>
64+
</ClCompile>
5965
</ItemGroup>
6066
</Project>

Fractal Images/ZoomList.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
#include<iostream>
12
#include "ZoomList.h"
23

4+
using namespace std;
5+
36
namespace fractal {
47

58
ZoomList::ZoomList(int width, int height) : m_width(width), m_height(height) {
@@ -8,6 +11,14 @@ namespace fractal {
811

912
void ZoomList::add(const Zoom& zoom) {
1013
zooms.push_back(zoom);
14+
15+
16+
m_xCenter += (zoom.x - m_width / 2) * m_scale;
17+
m_yCenter += (zoom.y - m_height / 2) * m_scale;
18+
19+
m_scale *= zoom.scale;
20+
21+
cout << m_xCenter << ", " << m_yCenter << ", " << m_scale << endl;
1122
}
1223

1324
pair<double, double> ZoomList::doZoom(int x, int y) {

Fractal Images/ZoomList.h

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ namespace fractal {
1313

1414
class ZoomList{
1515
private:
16+
double m_xCenter{0};
17+
double m_yCenter{0};
18+
double m_scale{1.0};
1619
int m_width{0};
1720
int m_height{0};
1821
vector<Zoom> zooms;

Fractal Images/main.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include"Bitmap.h"
1010
#include"Mandelbrot.h"
11+
#include"Zoom.h"
1112
#include "ZoomList.h"
1213

1314
using namespace std;
@@ -24,6 +25,10 @@ int main() {
2425

2526
double min = 99999;
2627
double max = -99999;
28+
29+
ZoomList zoomList(WIDTH, HEIGHT);
30+
31+
zoomList.add(Zoom(WIDTH/2, HEIGHT/2, 1));
2732

2833
unique_ptr<int[]> histogram(new int[Mandelbrot::MAX_ITERATIONS]());
2934
unique_ptr<int[]> fractal(new int[WIDTH * HEIGHT]());
@@ -81,14 +86,9 @@ int main() {
8186

8287
int count = 0;
8388
for (int i = 0; i < Mandelbrot::MAX_ITERATIONS; i++) {
84-
cout << histogram[i] << " " << flush;
8589
count += histogram[i];
8690
}
8791

88-
cout << count << " : " << WIDTH * HEIGHT << endl;
89-
90-
cout << endl;
91-
9292

9393
bitmap.write("test.bmp");
9494

0 commit comments

Comments
 (0)