/// File: noiseGen.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 NOISE_GEN_HH #define NOISE_GEN_HH #include <pch.hh> #include <random> #include <unordered_map> #include <generators/baseGen.hh> namespace ty { class noiseGen : public baseGen { using colorRange = std::pair<unsigned char, unsigned char>; private: /// pointless class, but I wanted syntax class noiseData { private: std::vector<colorRange> colors_; size_t atColor(const char& c) const; public: noiseData(); ~noiseData(); noiseData(const noiseData&) = delete; colorRange& operator[](const char& c); const colorRange& operator[](const char& c) const; }; std::random_device rd_; std::mt19937 gen_; std::uniform_int_distribution<unsigned char> dist_; /// used to load json settings const std::unordered_map<std::string, char> colorMap_ = {{"Red", 'r'}, {"Green", 'g'}, {"Blue", 'b'}}; noiseData noiseData_; unsigned char getRandom(const char& c); colorRange rangeClamp(const int& left, const int& right); public: noiseGen(const int& width, const int& height); ~noiseGen(); noiseGen(const noiseGen&) = delete; std::vector<unsigned char> runGen() override; void loadJson(const json& j) override; }; } /// ty #endif /// NOISE_GEN_HH