43#include "ramCanvas.hpp"
46const int MAXITR = 1024*1;
48double ranges[3][4] = { { -2.0, 1.0, -1.5, 1.5 },
49 { -0.12, -0.03, -0.92, -0.81 },
50 { 0.0353469, 0.5353469, 0.1153845, 0.6153845 }
53enum class whyStopMB {OUTSET, MAXCOUNT, INSET};
56typedef mjr::ramCanvas3c8b rc;
57typedef rc::colorType rcc;
61 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
62 const int CSIZE = 1024*1;
63 const rc::coordFltType BALL = 100;
64 rc binRamCanvas(CSIZE, CSIZE), grayRamCanvas(CSIZE, CSIZE), quadRamCanvas(CSIZE, CSIZE);
67 for(
int i=0; i<3; i++) {
68 binRamCanvas.newRealCoords(ranges[i][0], ranges[i][1], ranges[i][2], ranges[i][3]);
69 binRamCanvas.clrCanvasToBlack();
70 std::complex<rc::coordFltType> z;
71 for(rc::coordIntType y=0;y<binRamCanvas.getNumPixY();y++) {
73 std::cout <<
" CASE: " << i <<
" LINE: " << y <<
"/" << CSIZE << std::endl;
74 for(rc::coordIntType x=0;x<binRamCanvas.getNumPixX();x++) {
76 rc::coordFltType cr = binRamCanvas.int2realX(x);
77 rc::coordFltType ci = binRamCanvas.int2realY(y);
78 std::complex<rc::coordFltType> c(cr, ci);
79 rc::coordFltType p = std::abs(c-0.25);
80 if((cr >= p-2.0*p*p+0.25) && std::abs(c+1.0) >= 0.25) {
82 for(count=0; ; count++) {
84 why = whyStopMB::MAXCOUNT;
87 if(std::abs(z)>BALL) {
88 why = whyStopMB::OUTSET;
94 why = whyStopMB::INSET;
97 if(why == whyStopMB::OUTSET) {
98 rc::coordFltType zAbs = std::abs(z);
100 rcc::channelType ns = ( std::imag(z) > 0 ? 0 : 255 );
101 rcc::channelType ew = ( std::real(z) > 0 ? 0 : 255 );
102 grayRamCanvas.drawPoint(x, y, mjr::color3c8b::csCCdiag01::c(
static_cast<mjr::ramCanvas3c8b::csIntType
>(mjr::math::linm::scl_real_to_int((std::real(z) / zAbs + 1.0) / 2.0, 255))));
103 binRamCanvas.drawPoint(x, y, rcc(ns, ns, ns));
104 quadRamCanvas.drawPoint(x, y, rcc(ns,
static_cast<rcc::channelType
>(255-(ns+ew)/2), ew));
107 grayRamCanvas.drawPoint(x, y,
"red");
108 binRamCanvas.drawPoint(x, y,
"red");
109 quadRamCanvas.drawPoint(x, y,
"red");
114 binRamCanvas.writeTIFFfile(
"mandelbrot_binary_bin_" + std::to_string(i) +
".tiff");
115 grayRamCanvas.writeTIFFfile(
"mandelbrot_binary_gray_" + std::to_string(i) +
".tiff");
116 quadRamCanvas.writeTIFFfile(
"mandelbrot_binary_quad_" + std::to_string(i) +
".tiff");
119 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
120 std::cout <<
"Total Runtime " << runTime.count() <<
" sec" << std::endl;
int main(int argc, char *argv[])