diff options
Diffstat (limited to 'fractal.h')
| -rw-r--r-- | fractal.h | 97 |
1 files changed, 97 insertions, 0 deletions
| diff --git a/fractal.h b/fractal.h new file mode 100644 index 0000000..af098f4 --- /dev/null +++ b/fractal.h | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | #ifndef FRACTAL_H_0585D362 | ||
| 2 | #define FRACTAL_H_0585D362 | ||
| 3 | |||
| 4 | #include <map> | ||
| 5 | #include <string> | ||
| 6 | #include <vector> | ||
| 7 | #include <list> | ||
| 8 | #include "matrix3x3.h" | ||
| 9 | #include "color.h" | ||
| 10 | |||
| 11 | class Variation { | ||
| 12 | public: | ||
| 13 | enum class Type { | ||
| 14 | linear, | ||
| 15 | sinusoidal, | ||
| 16 | spherical, | ||
| 17 | eyefish, | ||
| 18 | bubble, | ||
| 19 | cylinder, | ||
| 20 | noise, | ||
| 21 | blur, | ||
| 22 | horseshoe, | ||
| 23 | swirl, | ||
| 24 | julian, | ||
| 25 | hyperbolic, | ||
| 26 | polar, | ||
| 27 | handkerchief, | ||
| 28 | heart, | ||
| 29 | disc, | ||
| 30 | spiral, | ||
| 31 | diamond, | ||
| 32 | ex, | ||
| 33 | julia, | ||
| 34 | bent, | ||
| 35 | fisheye | ||
| 36 | }; | ||
| 37 | |||
| 38 | Variation(Type _type, double _weight, std::vector<double> _params = {}); | ||
| 39 | |||
| 40 | const Type type; | ||
| 41 | const double weight; | ||
| 42 | const std::vector<double> params; | ||
| 43 | }; | ||
| 44 | |||
| 45 | class Fractal { | ||
| 46 | public: | ||
| 47 | void set_palette(std::string colors); | ||
| 48 | void add_transform(double weight, Matrix3x3 transform, double color, std::vector<Variation> variations); | ||
| 49 | void sample(double& x, double& y, double& c) const; | ||
| 50 | Color get_color(double c) const; | ||
| 51 | |||
| 52 | static int load(const char* filename, Fractal& fractal); | ||
| 53 | static Fractal random(); | ||
| 54 | |||
| 55 | double filterlevel = 0.5; | ||
| 56 | double gamma = 2.2; | ||
| 57 | double gammathresh = 0.01; | ||
| 58 | double brightness = 4.0; | ||
| 59 | double width = 800.0; | ||
| 60 | double height = 640.0; | ||
| 61 | |||
| 62 | private: | ||
| 63 | friend class FractalParser; | ||
| 64 | |||
| 65 | struct Transform { | ||
| 66 | Matrix3x3 transform; | ||
| 67 | double color; | ||
| 68 | std::vector<Variation> variations; | ||
| 69 | |||
| 70 | Transform() | ||
| 71 | { | ||
| 72 | |||
| 73 | } | ||
| 74 | |||
| 75 | Transform(Matrix3x3 transform, double color, std::vector<Variation> variations) : transform(transform), color(color), variations(variations) | ||
| 76 | { | ||
| 77 | |||
| 78 | } | ||
| 79 | }; | ||
| 80 | |||
| 81 | std::map<double, Transform> transforms; | ||
| 82 | double max = 0.0; | ||
| 83 | std::vector<Color> palette; | ||
| 84 | }; | ||
| 85 | |||
| 86 | class LogScale { | ||
| 87 | public: | ||
| 88 | LogScale(double brightness, double quality); | ||
| 89 | double log(double n) const; | ||
| 90 | |||
| 91 | private: | ||
| 92 | std::vector<double> memo; | ||
| 93 | double k1; | ||
| 94 | double k2; | ||
| 95 | }; | ||
| 96 | |||
| 97 | #endif /* end of include guard: FRACTAL_H_0585D362 */ | ||
