Nature.h
Go to the documentation of this file.
1 /**
2  * This file was automatically created with "create_c++_header.sh".
3  * Do not edit manually.
4  */
5 #pragma once
6 #include "../../colormap.h"
7 
8 namespace colormap
9 {
10  namespace IDL
11  {
12 
13  class Nature : public Colormap
14  {
15  private:
16  class Wrapper : public WrapperBase
17  {
18  public:
19 #ifdef float
20 #error "TODO"
21 #endif
22 #define float local_real_t
23 #include "../../../../shaders/glsl/IDL_Nature.frag"
24 #undef float
25  };
26 
27  public:
28  Color getColor(double x) const override
29  {
30  Wrapper w;
31  vec4 c = w.colormap(x);
32  Color result;
33  result.r = std::max(0.0, std::min(1.0, c.r));
34  result.g = std::max(0.0, std::min(1.0, c.g));
35  result.b = std::max(0.0, std::min(1.0, c.b));
36  result.a = std::max(0.0, std::min(1.0, c.a));
37  return result;
38  }
39 
40  std::string getTitle() const override
41  {
42  return std::string("Nature");
43  }
44 
45  std::string getCategory() const override
46  {
47  return std::string("IDL");
48  }
49 
50  std::string getSource() const override
51  {
52  return std::string(
53  "float colormap_red(float x) {\n"
54  " if (x < 0.8) {\n"
55  " const float pi = 3.141592653589793238462643383279502884197169399;\n"
56  " float v = sin(2.0 * pi * (x * 2.440771851872335 + 0.03082889566781979)) * 94.0 + 86.68712190457872;\n"
57  " if (v < 0.0) {\n"
58  " return -v;\n"
59  " } else {\n"
60  " return v;\n"
61  " }\n"
62  " } else {\n"
63  " return 82.0;\n"
64  " }\n"
65  "}\n"
66  "\n"
67  "float colormap_green(float x) {\n"
68  " if (x < 0.8) {\n"
69  " const float pi = 3.141592653589793238462643383279502884197169399;\n"
70  " const float a = - 133.8180196373718;\n"
71  " const float b = 105.5963045788319;\n"
72  " const float c = 1.192621559448461;\n"
73  " const float d = 4.00554233186818;\n"
74  " const float e = 0.04779355732364274;\n"
75  " const float f = 218.2356517672776;\n"
76  " const float g = -269.6049419208264;\n"
77  " float v = (a * x + b) * sin(2.0 * pi / c * (d * x + e)) + f + g * x;\n"
78  " if (v > 255.0) {\n"
79  " return 255.0 - (v - 255.0);\n"
80  " } else {\n"
81  " return v;\n"
82  " }\n"
83  " } else {\n"
84  " return 0.0;\n"
85  " }\n"
86  "}\n"
87  "\n"
88  "float colormap_blue(float x) {\n"
89  " if (x < 0.8) {\n"
90  " const float pi = 3.141592653589793238462643383279502884197169399;\n"
91  " const float a = 2.443749115965466;\n"
92  " const float b = 0.02934035424870109;\n"
93  " const float c = 253.745120022022;\n"
94  " const float d = 226.671125688366;\n"
95  " float v = sin(2.0 * pi * (x * a + b))*c + d;\n"
96  " if (v > 255.0) {\n"
97  " return 255.0 - (v - 255.0);\n"
98  " } else if (v < 0.0) {\n"
99  " return -v;\n"
100  " } else {\n"
101  " return v;\n"
102  " }\n"
103  " } else {\n"
104  " return 214.0;\n"
105  " }\n"
106  "}\n"
107  "\n"
108  "vec4 colormap(float x) {\n"
109  " float r = clamp(colormap_red(x) / 255.0, 0.0, 1.0);\n"
110  " float g = clamp(colormap_green(x) / 255.0, 0.0, 1.0);\n"
111  " float b = clamp(colormap_blue(x) / 255.0, 0.0, 1.0);\n"
112  " return vec4(r, g, b, 1.0);\n"
113  "}\n"
114  );
115  }
116  };
117 
118  } // namespace IDL
119 } // namespace colormap
colormap::Colormap
Definition: colormap.h:17
colormap::Color::g
double g
Definition: colormap.h:14
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
colormap::Colormap::vec4
Definition: colormap.h:32
colormap::IDL::Nature::getCategory
std::string getCategory() const override
Definition: Nature.h:45
colormap::IDL::Nature::getColor
Color getColor(double x) const override
Definition: Nature.h:28
colormap::Color::a
double a
Definition: colormap.h:14
colormap::Color::b
double b
Definition: colormap.h:14
max
T max(T t1, T t2)
Definition: gdiam.h:48
colormap::IDL::Nature
Definition: Nature.h:13
colormap::Color
Definition: colormap.h:12
colormap::IDL::Nature::getSource
std::string getSource() const override
Definition: Nature.h:50
colormap
This file was automatically created with "create_c++_header.sh".
Definition: colormap.h:9
colormap::Color::r
double r
Definition: colormap.h:14
colormap::Colormap::WrapperBase
Definition: colormap.h:144
min
T min(T t1, T t2)
Definition: gdiam.h:42
colormap::IDL::Nature::getTitle
std::string getTitle() const override
Definition: Nature.h:40