MRaster examples 21.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
pickoverPopcorn.cpp
Go to the documentation of this file.
1// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
2/*******************************************************************************************************************************************************.H.S.**/
3/**
4 @file pickoverPopcorn.cpp
5 @author Mitch Richling <https://www.mitchr.me>
6 @brief Draw Pickover Popcorn Fractals.@EOL
7 @std C++20
8 @see https://www.mitchr.me/SS/PickoverPopcorn/index.html
9 @copyright
10 @parblock
11 Copyright (c) 1988-2015, Mitchell Jay Richling <https://www.mitchr.me> All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
14
15 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
16
17 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 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
21 without specific prior written permission.
22
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 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
28 DAMAGE.
29 @endparblock
30 @filedetails
31
32 Fractals inspired by the book "Computers, Pattern, Chaos and Beauty" by Clifford A. Pickover
33
34*/
35/*******************************************************************************************************************************************************.H.E.**/
36/** @cond exj */
37
38//--------------------------------------------------------------------------------------------------------------------------------------------------------------
39#include "ramCanvas.hpp"
40
41//--------------------------------------------------------------------------------------------------------------------------------------------------------------
42// This is *identical* to what we did in sic.cpp -- just way shorter.
43typedef mjr::ramCanvas1c16b::rcConverterColorScheme<mjr::ramCanvas1c16b, mjr::color3c8b, mjr::color3c8b::csCCfractal0RYBCW, true, 10, 0> g2rgb8;
44
45//--------------------------------------------------------------------------------------------------------------------------------------------------------------
46int main(void) {
47 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
48 const int IMXSIZ = 7680/2;
49 const int IMYSIZ = 4320/2;
50 const int NUMITR = 100;
51 const int spanx = 1;
52 const int spany = 1;
53 const double h = 0.05;
54 const double a = 3.0;
55 const double b = 3.0;
56 mjr::ramCanvas1c16b hstRamCanvas(IMXSIZ, IMYSIZ, -4.0, 4.0, -2.25, 2.25);
57
58 for(int y=0;y<hstRamCanvas.getNumPixY();y+=spany) {
59 if ((y%100)==0)
60 std::cout << y << std::endl;
61 for(int x=0;x<hstRamCanvas.getNumPixX();x+=spanx) {
62 double zx = hstRamCanvas.int2realX(x);
63 double zy = hstRamCanvas.int2realY(y);
64 for(int i=0; i<NUMITR; i++) {
65 double tmpx = zx - h * std::sin(zy + std::tan(a * zy));
66 double tmpy = zy - h * std::sin(zx + std::tan(b * zx));
67 zx = tmpx;
68 zy = tmpy;
69 int ix = hstRamCanvas.real2intX(zx);
70 int iy = hstRamCanvas.real2intY(zy);
71 if (hstRamCanvas.isOnCanvas(ix, iy))
72 hstRamCanvas.getPxColorRefNC(ix, iy).tfrmAdd(1);
73 }
74 }
75 }
76 hstRamCanvas.writeTIFFfile("pickoverPopcornCNT.tiff");
77 g2rgb8 rcFilt(hstRamCanvas);
78 hstRamCanvas.writeTIFFfile("pickoverPopcornCOL.tiff", rcFilt, false);
79 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
80 std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl;
81 return 0;
82}
83/** @endcond */
int main(int argc, char *argv[])