/// File: fracGen.hh /// Copyright (C) 2025 Tyler Triplett /// License: GNU GPL 3.0 or later <https://www.gnu.org/licenses/gpl-3.0.html> /// /// This is free software: you can redistribute it and/or modify it /// under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// This program is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. #ifndef FRAC_GEN_HH #define FRAC_GEN_HH #include <pch.hh> #include <generators/baseGen.hh> #include <vector> #include <complex> namespace ty { class fracGen : public baseGen { protected: /// faster than a vector struct pixel { const unsigned char r_; const unsigned char g_; const unsigned char b_; }; /// base consts const double range_ = 1.5; const double iterLimit_ = 5000.0; /// base settings double zoomFactor_ = 1.0; double realCenter_ = 0.0; double imagCenter_ = 0.0; double maxIter_ = 1000; /// used to load settings std::vector<std::pair<std::string, double&>> settings = { {"zf", zoomFactor_}, {"rc", realCenter_}, {"ic", imagCenter_}, {"it", maxIter_}}; /// computed by setMembers. they allow for any dimension image. double minX_ = 0; double maxX_ = 0; double minY_ = 0; double maxY_ = 0; double scaleX_ = 0; double scaleY_ = 0; /// regular functions std::pair<double, double> scaleRange() const; pixel pixelFromIt(const int& it) const; std::complex<double> pixelTranslation(const int& px, const int& py) const; virtual void setMembers(); virtual int computeIteration(const int& px, const int& py) const = 0; public: fracGen(const int& w, const int& h); virtual ~fracGen(); fracGen(const fracGen&) = delete; void loadJson(const json& j) override; std::vector<unsigned char> runGen() override; }; } /// ty #endif /// FRAC_GEN_HH