40#include "ramCanvas.hpp"
43typedef mjr::ramCanvas3c8b::colorType ct;
47 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
48 const int JULIA_MAXITR = 1024;
49 const double JULIA_MAXZSQ = 4.0;
50 const int IMGSIZ = 7680/8;
51 const int MANDL_MAXITR = 1024;
52 const double MANDL_MAXZSQ = 4.0;
53 mjr::ramCanvas3c8b manRamCanvas(IMGSIZ, IMGSIZ, -2.2, 0.8, -1.5, 1.5);
56 std::vector<double> mcX;
57 std::vector<double> mcY;
59 std::ifstream iStream(
"../data/mandelbrot_curve_10.txt", std::ios_base::binary);
60 if (!(iStream.good()))
62 while(iStream.good()) {
63 iStream.getline(strBuf, 100,
'\n');
64 std::string strBufS(strBuf);
65 if (strBufS.length() > 0) {
66 std::string::size_type pos;
67 std::string::size_type tagIdx = strBufS.find_first_of(
"\t ,");
68 mcX.push_back(std::stod(strBufS.substr(0, tagIdx), &pos));
69 mcY.push_back(std::stod(strBufS.substr(tagIdx+1), &pos));
72 int numPts =
static_cast<int>(mcX.size());
75 for(
int y=0;y<manRamCanvas.getNumPixY();y++) {
76 for(
int x=0;x<manRamCanvas.getNumPixX();x++) {
77 std::complex<double> c = manRamCanvas.int2real(x, y);
78 std::complex<double> z(0.0, 0.0);
80 while((std::norm(z)<MANDL_MAXZSQ) && (count<=MANDL_MAXITR)) {
84 if(count < MANDL_MAXITR)
85 manRamCanvas.drawPoint(x, y, ct::csCColdeFireRamp::c(
static_cast<ct::csIntType
>(count*20)));
89 for(
int frame=0; frame<numPts; frame++)
90 manRamCanvas.drawLine(mcX[frame], mcY[frame], mcX[(frame+1)%numPts], mcY[(frame+1)%numPts],
"white");
93 for(
int frame=0; frame<numPts; frame++) {
95 mjr::ramCanvas3c8b julRamCanvas(IMGSIZ, IMGSIZ, -2.2, 2.2, -2.2, 2.2);
96 std::cout <<
"Frame: " << frame <<
" of " << numPts << std::endl;
97 std::complex<double> c = std::complex<double>(mcX[frame], mcY[frame]);
98 for(
int y=0;y<julRamCanvas.getNumPixY();y++) {
99 for(
int x=0;x<julRamCanvas.getNumPixX();x++) {
100 std::complex<double> z(julRamCanvas.int2realX(x), julRamCanvas.int2realY(y));
102 while((std::norm(z)<JULIA_MAXZSQ) && (count<=JULIA_MAXITR)) {
103 z=std::pow(z, 2) + c;
106 if(count < JULIA_MAXITR)
107 julRamCanvas.drawPoint(x, y, ct::csCColdeFireRamp::c(
static_cast<ct::csIntType
>(count*20)));
111 mjr::ramCanvas3c8b setRamCanvas(manRamCanvas);
112 setRamCanvas.drawFillCircle(c, 0.04,
"white");
113 setRamCanvas.scaleDownMean(4);
114 julRamCanvas.insertCanvas(setRamCanvas, 0, 0);
115 julRamCanvas.drawRectangle(0, 0, IMGSIZ/4, IMGSIZ/4,
"white");
117 julRamCanvas.drawString(
"MJR 2022", mjr::hershey::font::ROMAN_SL_SANSERIF, IMGSIZ-IMGSIZ/6, 20,
"white", 1, 20);
119 julRamCanvas.writeTIFFfile(
"juliaM2_" + mjr::math::str::fmt_int(frame, 3,
'0') +
".tiff");
122 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
123 std::cout <<
"Total Runtime " << runTime.count() <<
" sec" << std::endl;
int main(int argc, char *argv[])