From 330f75e663c22e1198a92fd134865ada98c3957b Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 2 May 2016 22:57:13 -0400 Subject: Initial commit --- fractal.h | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 fractal.h (limited to 'fractal.h') diff --git a/fractal.h b/fractal.h new file mode 100644 index 0000000..af098f4 --- /dev/null +++ b/fractal.h @@ -0,0 +1,97 @@ +#ifndef FRACTAL_H_0585D362 +#define FRACTAL_H_0585D362 + +#include +#include +#include +#include +#include "matrix3x3.h" +#include "color.h" + +class Variation { + public: + enum class Type { + linear, + sinusoidal, + spherical, + eyefish, + bubble, + cylinder, + noise, + blur, + horseshoe, + swirl, + julian, + hyperbolic, + polar, + handkerchief, + heart, + disc, + spiral, + diamond, + ex, + julia, + bent, + fisheye + }; + + Variation(Type _type, double _weight, std::vector _params = {}); + + const Type type; + const double weight; + const std::vector params; +}; + +class Fractal { + public: + void set_palette(std::string colors); + void add_transform(double weight, Matrix3x3 transform, double color, std::vector variations); + void sample(double& x, double& y, double& c) const; + Color get_color(double c) const; + + static int load(const char* filename, Fractal& fractal); + static Fractal random(); + + double filterlevel = 0.5; + double gamma = 2.2; + double gammathresh = 0.01; + double brightness = 4.0; + double width = 800.0; + double height = 640.0; + + private: + friend class FractalParser; + + struct Transform { + Matrix3x3 transform; + double color; + std::vector variations; + + Transform() + { + + } + + Transform(Matrix3x3 transform, double color, std::vector variations) : transform(transform), color(color), variations(variations) + { + + } + }; + + std::map transforms; + double max = 0.0; + std::vector palette; +}; + +class LogScale { + public: + LogScale(double brightness, double quality); + double log(double n) const; + + private: + std::vector memo; + double k1; + double k2; +}; + +#endif /* end of include guard: FRACTAL_H_0585D362 */ -- cgit 1.4.1