MRaster examples 21.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
multibrotMovie.cpp
Go to the documentation of this file.
1// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
2/*******************************************************************************************************************************************************.H.S.**/
3/**
4 @file multibrotMovie.cpp
5 @author Mitch Richling <https://www.mitchr.me>
6 @brief Render movie frames for a smooth multibrot evolution from k=.9 to k=4.@EOL
7 @std C++20
8 @see https://www.mitchr.me/SS/multibrot/index.html
9 @copyright
10 @parblock
11 Copyright (c) 1988-2022, 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*/
31/*******************************************************************************************************************************************************.H.E.**/
32/** @cond exj */
33
34//--------------------------------------------------------------------------------------------------------------------------------------------------------------
35#include "ramCanvas.hpp"
36
37//--------------------------------------------------------------------------------------------------------------------------------------------------------------
38int main(void) {
39 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
40 const double MINPOW = 0.9;
41 const double MAXPOW = 4.0;
42 const int NUMFRM = 192;
43 const int NUMITR = 255;
44 const int IMXSIZ = 7680/8;
45 const int IMYSIZ = 4320/8;
46
47 mjr::ramCanvas3c8b theRamCanvas(IMXSIZ, IMYSIZ, -2.75, 2.75, -1.55, 1.55);
48
49 for(int f=0;f<NUMFRM;f++) {
50 double p = MAXPOW*static_cast<double>(f)/static_cast<double>(NUMFRM) + MINPOW;
51 std::chrono::time_point<std::chrono::system_clock> frameStartTime = std::chrono::system_clock::now();
52 theRamCanvas.clrCanvasToBlack();
53 for(int y=0;y<theRamCanvas.getNumPixY();y++) {
54 for(int x=0;x<theRamCanvas.getNumPixX();x++) {
55 std::complex<double> c(theRamCanvas.int2realX(x), theRamCanvas.int2realY(y));
56 std::complex<double> z(0.0, 0.0);
57 int count = 0;
58 while((std::norm(z)<4) && (count<=NUMITR)) {
59 z=std::pow(z, p) + c;
60 count++;
61 }
62 if(count < NUMITR)
63 theRamCanvas.drawPoint(x, y, mjr::ramCanvas3c8b::colorType::csCColdeFireRamp::c(static_cast<mjr::ramCanvas3c8b::csIntType>(count*20)));
64 }
65 }
66 theRamCanvas.writeTIFFfile("multibrotMovie_" + mjr::math::str::fmt_int(f, 3, '0') + ".tiff");
67 std::chrono::duration<double> frameRunTime = std::chrono::system_clock::now() - frameStartTime;
68 std::cout << "Frame " << f << " Runtime " << frameRunTime.count() << " sec" << std::endl;
69 }
70 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
71 std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl;
72}
73/** @endcond */
int main(int argc, char *argv[])