Eos_A.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 EosA : 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_Eos_A.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("Eos_A");
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_h(float x) {\n"
54  " if (x < 0.1151580585723306) {\n"
55  " return (2.25507158009032E+00 * x - 1.17973110308697E+00) * x + 7.72551618145170E-01; // H1\n"
56  " } else if (x < (9.89643667779019E-01 - 6.61604251019618E-01) / (2.80520737708568E+00 - 1.40111938331467E+00)) {\n"
57  " return -2.80520737708568E+00 * x + 9.89643667779019E-01; // H2\n"
58  " } else if (x < (6.61604251019618E-01 - 4.13849520734156E-01) / (1.40111938331467E+00 - 7.00489176507247E-01)) {\n"
59  " return -1.40111938331467E+00 * x + 6.61604251019618E-01; // H3\n"
60  " } else if (x < (4.13849520734156E-01 - 2.48319927251200E-01) / (7.00489176507247E-01 - 3.49965224045823E-01)) {\n"
61  " return -7.00489176507247E-01 * x + 4.13849520734156E-01; // H4\n"
62  " } else {\n"
63  " return -3.49965224045823E-01 * x + 2.48319927251200E-01; // H5\n"
64  " }\n"
65  "}\n"
66  "\n"
67  "float colormap_v(float x) {\n"
68  " float v = 1.0;\n"
69  " if (x < 0.5) {\n"
70  " v = clamp(2.10566088679245E+00 * x + 7.56360684411500E-01, 0.0, 1.0);\n"
71  " } else {\n"
72  " v = clamp(-1.70132918347782E+00 * x + 2.20637371757606E+00, 0.0, 1.0);\n"
73  " }\n"
74  " float period = 4.0 / 105.0;\n"
75  " float len = 3.0 / 252.0;\n"
76  " float t = mod(x + 7.0 / 252.0, period);\n"
77  " if (0.0 <= t && t < len) {\n"
78  " if (x < 0.12) {\n"
79  " v = (1.87862631683169E+00 * x + 6.81498517051705E-01);\n"
80  " } else if (x < 0.73) {\n"
81  " v -= 26.0 / 252.0; \n"
82  " } else {\n"
83  " v = -1.53215278202992E+00 * x + 1.98649818445446E+00;\n"
84  " }\n"
85  " }\n"
86  " return v;\n"
87  "}\n"
88  "\n"
89  "// H1 - H2 = 0\n"
90  "// => [x=-0.8359672286003642,x=0.1151580585723306]\n"
91  "\n"
92  "vec4 colormap_hsv2rgb(float h, float s, float v) {\n"
93  " float r = v;\n"
94  " float g = v;\n"
95  " float b = v;\n"
96  " if (s > 0.0) {\n"
97  " h *= 6.0;\n"
98  " int i = int(h);\n"
99  " float f = h - float(i);\n"
100  " if (i == 1) {\n"
101  " r *= 1.0 - s * f;\n"
102  " b *= 1.0 - s;\n"
103  " } else if (i == 2) {\n"
104  " r *= 1.0 - s;\n"
105  " b *= 1.0 - s * (1.0 - f);\n"
106  " } else if (i == 3) {\n"
107  " r *= 1.0 - s;\n"
108  " g *= 1.0 - s * f;\n"
109  " } else if (i == 4) {\n"
110  " r *= 1.0 - s * (1.0 - f);\n"
111  " g *= 1.0 - s;\n"
112  " } else if (i == 5) {\n"
113  " g *= 1.0 - s;\n"
114  " b *= 1.0 - s * f;\n"
115  " } else {\n"
116  " g *= 1.0 - s * (1.0 - f);\n"
117  " b *= 1.0 - s;\n"
118  " }\n"
119  " }\n"
120  " return vec4(r, g, b, 1.0);\n"
121  "}\n"
122  "\n"
123  "vec4 colormap(float x) {\n"
124  " float h = colormap_h(clamp(x, 0.0, 1.0));\n"
125  " float s = 1.0;\n"
126  " float v = colormap_v(clamp(x, 0.0, 1.0));\n"
127  " return colormap_hsv2rgb(h, s, v);\n"
128  "}\n"
129  );
130  }
131  };
132 
133  } // namespace IDL
134 } // namespace colormap
colormap::IDL::EosA::getSource
std::string getSource() const override
Definition: Eos_A.h:50
colormap::Colormap
Definition: colormap.h:17
colormap::IDL::EosA::getColor
Color getColor(double x) const override
Definition: Eos_A.h:28
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::EosA::getTitle
std::string getTitle() const override
Definition: Eos_A.h:40
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::Color
Definition: colormap.h:12
colormap::IDL::EosA::getCategory
std::string getCategory() const override
Definition: Eos_A.h:45
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::EosA
Definition: Eos_A.h:13