MRaster examples 21.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
BurningShip.cpp
Go to the documentation of this file.
1// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
2/*******************************************************************************************************************************************************.H.S.**/
3/**
4 @file BurningShip.cpp
5 @author Mitch Richling http://www.mitchr.me/
6 @date 2022-09-08
7 @brief Burning Ship Fractal.@EOL
8 @std C++20
9 @see https://www.mitchr.me/SS/BurningShip/index.html
10 @copyright
11 @parblock
12 Copyright (c) 2022, Mitchell Jay Richling <http://www.mitchr.me/> All rights reserved.
13
14 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
15
16 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
17
18 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation
19 and/or other materials provided with the distribution.
20
21 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software
22 without specific prior written permission.
23
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
29 DAMAGE.
30 @endparblock
31*/
32/*******************************************************************************************************************************************************.H.E.**/
33/** @cond exj */
34
35//--------------------------------------------------------------------------------------------------------------------------------------------------------------
36#include "ramCanvas.hpp"
37
38//--------------------------------------------------------------------------------------------------------------------------------------------------------------
39typedef mjr::color3c8b::csCC_tpl<mjr::color3c8b::cornerColorEnum::BLUE,
40 mjr::color3c8b::cornerColorEnum::RED,
41 mjr::color3c8b::cornerColorEnum::YELLOW,
42 mjr::color3c8b::cornerColorEnum::WHITE> csCCbs;
43
44//--------------------------------------------------------------------------------------------------------------------------------------------------------------
45int main(void) {
46 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
47 const int NUMITR = 1024;
48 const int MAXMAG = 15;
49 const int IMGSIZ = 7680/4;
50 //mjr::ramCanvas3c8b escRamCanvas(IMGSIZ, IMGSIZ, -1.5, 2.7, -1.25, 2.49); // Entire fractal
51 //mjr::ramCanvas3c8b escRamCanvas(IMGSIZ, IMGSIZ, 1.6, 1.9, -0.089, 0.2); // The horizon zoom
52 mjr::ramCanvas3c8b escRamCanvas(IMGSIZ, IMGSIZ, 1.715, 1.795, -0.022, 0.086); // The classic zoom
53 //mjr::ramCanvas3c8b escRamCanvas(IMGSIZ, IMGSIZ, 1.802, 1.80287, -0.002, 0.002); // Columns to heaven
54 //mjr::ramCanvas3c8b escRamCanvas(IMGSIZ, IMGSIZ, -0.3743, -0.3735, -0.0876, -0.0866); // Deep zoom. BATS!
55
56 for(int y=0;y<escRamCanvas.getNumPixY();y++) {
57 for(int x=0;x<escRamCanvas.getNumPixX();x++) {
58 double cx = escRamCanvas.int2realX(x), cy = escRamCanvas.int2realY(y);
59 double zx = 0.0, zy = 0.0;
60 double t;
61 int count = 0;
62 while(((zx*zx+zy*zy)<MAXMAG) && (count<=NUMITR)) {
63 count++;
64 t = zx*zx - zy*zy - cx;
65 zy = std::abs(2*zx*zy) - cy;
66 zx = t;
67 }
68 if(count < NUMITR)
69 escRamCanvas.drawPoint(x, y, csCCbs::c(static_cast<mjr::ramCanvas3c8b::csIntType>(count*10)));
70 }
71 }
72 // Escape Time Coloring
73 escRamCanvas.writeTIFFfile("BurningShip.tiff");
74 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
75 std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl;
76}
77/** @endcond */
int main(int argc, char *argv[])