diff --git a/README.md b/README.md index 2e14cc5..320cbbc 100644 --- a/README.md +++ b/README.md @@ -382,8 +382,8 @@ be changed. ![Escape Time colorbars](https://crapp.github.io/geomandel/escape_colorbar_1band.png) The next three colorbars were created with the same base color and the same frequency -values for the green primary. Additionally I have added a frequency of 4 for the -blue primary. +values for the green channel. Additionally I have added a frequency of 4 for the +blue channel. ![Escape Time colorbars two color components](https://crapp.github.io/geomandel/escape_colorbar_2band.png) diff --git a/src/buffwriter.cpp b/src/buffwriter.cpp index c9554f2..f5ddd8e 100644 --- a/src/buffwriter.cpp +++ b/src/buffwriter.cpp @@ -23,8 +23,8 @@ Buffwriter::~Buffwriter() {} std::string Buffwriter::out_file_name(const std::string &string_pattern, unsigned int bailout, unsigned int xrange, unsigned int yrange, unsigned int zoom, - unsigned int cores, unsigned int xcoord, - unsigned int ycoord, double z_real_min, + unsigned int cores, double xcoord, + double ycoord, double z_real_min, double z_real_max, double z_ima_min, double z_ima_max) { @@ -36,8 +36,8 @@ std::string Buffwriter::out_file_name(const std::string &string_pattern, regex_patterns.emplace_back(new Regexpattern(yrange, "%h")); regex_patterns.emplace_back(new Regexpattern(zoom, "%z")); regex_patterns.emplace_back(new Regexpattern(cores, "%c")); - regex_patterns.emplace_back(new Regexpattern(xcoord, "%x")); - regex_patterns.emplace_back(new Regexpattern(ycoord, "%y")); + regex_patterns.emplace_back(new Regexpattern(xcoord, "%x")); + regex_patterns.emplace_back(new Regexpattern(ycoord, "%y")); regex_patterns.emplace_back(new Regexpattern(z_real_min, "%Zr")); regex_patterns.emplace_back(new Regexpattern(z_real_max, "%ZR")); regex_patterns.emplace_back(new Regexpattern(z_ima_min, "%Zi")); diff --git a/src/buffwriter.h b/src/buffwriter.h index 28168d1..4c20cd8 100644 --- a/src/buffwriter.h +++ b/src/buffwriter.h @@ -21,9 +21,12 @@ along with this program. If not, see . #include "global.h" +#include "mandelparams.h" + #include #include #include +#include /** * @brief Simple interface to be able to use objects with different @@ -43,7 +46,7 @@ struct Regexpattern : public RegexpatternIface { virtual ~Regexpattern(){}; /** - * @brief Parse the filename string and replace every occurence of regpattern + * @brief Parse the filename string and replace every occurence of regpattern * with value * * @param filename @@ -51,7 +54,16 @@ struct Regexpattern : public RegexpatternIface { void parse_filename(std::string &filename) { std::regex re(this->regpattern); - filename = std::regex_replace(filename, re, std::to_string(this->value)); + std::string val_string = std::to_string(this->value); + if (std::is_same::value) { + val_string.erase(val_string.find_last_not_of('0') + 1, + std::string::npos); + // check if last char is a point + if (val_string.back() == '.') { + val_string = val_string.substr(0, val_string.size() - 1); + } + } + filename = std::regex_replace(filename, re, val_string); } private: @@ -60,7 +72,7 @@ struct Regexpattern : public RegexpatternIface { }; /** - * @brief Base class of all classes that write the mandelbrot buffer to a + * @brief Base class of all classes that write the mandelbrot buffer to a * file/stream */ class Buffwriter @@ -77,10 +89,9 @@ class Buffwriter std::string out_file_name(const std::string &string_pattern, unsigned int bailout, unsigned int xrange, unsigned int yrange, unsigned int zoom, - unsigned int cores, unsigned int xcoord, - unsigned int ycoord, double z_real_min, - double z_real_max, double z_ima_min, - double z_ima_max); + unsigned int cores, double xcoord, double ycoord, + double z_real_min, double z_real_max, + double z_ima_min, double z_ima_max); }; #endif /* ifndef BUFFWRITER_H */ diff --git a/src/main_helper.h b/src/main_helper.h index c25b60b..5041995 100644 --- a/src/main_helper.h +++ b/src/main_helper.h @@ -53,8 +53,8 @@ inline void init_mandel_parameters(std::shared_ptr ¶ms, unsigned int yrange = parser["h"].as(); unsigned int zoomlvl = 0; - unsigned int xcoord = 0; - unsigned int ycoord = 0; + double xcoord = 0; + double ycoord = 0; // check if user wants to zoom if (parser.count("zoom")) { @@ -67,8 +67,8 @@ inline void init_mandel_parameters(std::shared_ptr ¶ms, parser["zoom"].as() == 0 ? zoomlvl = 1 : zoomlvl = parser["zoom"].as(); - xcoord = parser["xcoord"].as(); - ycoord = parser["ycoord"].as(); + xcoord = parser["xcoord"].as(); + ycoord = parser["ycoord"].as(); if (xcoord > xrange) { std::cerr << "X Coordinate outside of the image space" @@ -161,9 +161,9 @@ inline void configure_command_line_parser(cxxopts::Options &p) ("zoom", "Zoom level. Use together with xcoord, ycoord", cxxopts::value()) ("xcoord", "Image X coordinate where you want to zoom into the fractal", - cxxopts::value()) + cxxopts::value()) ("ycoord", "Image Y coordinate where you want to zoom into the fractal", - cxxopts::value()); + cxxopts::value()); p.add_options("Export") ("p,print", "Print Buffer to terminal") diff --git a/src/mandelparams.h b/src/mandelparams.h index 950ca4d..a78162e 100644 --- a/src/mandelparams.h +++ b/src/mandelparams.h @@ -39,8 +39,8 @@ struct MandelParameters { unsigned int bailout; unsigned int zoom; - unsigned int xcoord; - unsigned int ycoord; + double xcoord; + double ycoord; std::string image_base; @@ -52,7 +52,7 @@ struct MandelParameters { MandelParameters(unsigned int xrange, double xl, double xh, unsigned int yrange, double yl, double yh, unsigned int bailout, unsigned int zoom, - unsigned int xcoord, unsigned int ycoord, + double xcoord, double ycoord, std::string image_base, unsigned int cores, constants::COL_ALGO col_algo) : xrange(xrange), diff --git a/src/mandelzoom.cpp b/src/mandelzoom.cpp index 5f55351..e3e2c19 100644 --- a/src/mandelzoom.cpp +++ b/src/mandelzoom.cpp @@ -21,7 +21,7 @@ along with this program. If not, see . Mandelzoom::Mandelzoom() {} void Mandelzoom::calcalute_zoom_cpane(double &xh, double &xl, double &yh, double &yl, unsigned int zoom, - unsigned int xcoord, unsigned int ycoord, + double xcoord, double ycoord, unsigned int width, unsigned int height) { /* diff --git a/src/mandelzoom.h b/src/mandelzoom.h index 92d9e3e..4d54112 100644 --- a/src/mandelzoom.h +++ b/src/mandelzoom.h @@ -40,8 +40,8 @@ class Mandelzoom * @param ycoord Y coordinate in the complex plane */ void calcalute_zoom_cpane(double &xh, double &xl, double &yh, double &yl, - unsigned int zoom, unsigned int xcoord, - unsigned int ycoord, unsigned int width, + unsigned int zoom, double xcoord, + double ycoord, unsigned int width, unsigned int height); private: diff --git a/src/test/buffwriter_mock.cpp b/src/test/buffwriter_mock.cpp index aa030a9..7c71bd5 100644 --- a/src/test/buffwriter_mock.cpp +++ b/src/test/buffwriter_mock.cpp @@ -28,7 +28,7 @@ void BuffwriterMock::write_buffer(){}; std::string BuffwriterMock::test_filename_patterns( std::string filename_pattern, unsigned int bailout, unsigned int xrange, unsigned int yrange, unsigned int zoom, unsigned int cores, - unsigned int xcoord, unsigned int ycoord, double z_real_min, + double xcoord, double ycoord, double z_real_min, double z_real_max, double z_ima_min, double z_ima_max) { return this->out_file_name(filename_pattern, bailout, xrange, yrange, zoom, diff --git a/src/test/buffwriter_mock.h b/src/test/buffwriter_mock.h index a04b9cc..4096e71 100644 --- a/src/test/buffwriter_mock.h +++ b/src/test/buffwriter_mock.h @@ -31,8 +31,8 @@ class BuffwriterMock : public Buffwriter std::string test_filename_patterns(std::string filename_pattern, unsigned int bailout, unsigned int xrange, unsigned int yrange, unsigned int zoom, - unsigned int cores, unsigned int xcoord, - unsigned int ycoord, double z_real_min, + unsigned int cores, double xcoord, + double ycoord, double z_real_min, double z_real_max, double z_ima_min, double z_ima_max); diff --git a/src/test/test_computation.cpp b/src/test/test_computation.cpp index 344bcc9..859a886 100644 --- a/src/test/test_computation.cpp +++ b/src/test/test_computation.cpp @@ -80,8 +80,8 @@ TEST_CASE("Computation of zoom values", "[computation]") // zoom level unsigned int zoom = 30; // x/y coordinate in the image space - unsigned int xcoord = 200; - unsigned int ycoord = 300; + double xcoord = 200; + double ycoord = 300; SECTION("Test 30x zoom") {