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
29  getColor(double x) const override
30  {
31  Wrapper w;
32  vec4 c = w.colormap(x);
33  Color result;
34  result.r = std::max(0.0, std::min(1.0, c.r));
35  result.g = std::max(0.0, std::min(1.0, c.g));
36  result.b = std::max(0.0, std::min(1.0, c.b));
37  result.a = std::max(0.0, std::min(1.0, c.a));
38  return result;
39  }
40 
41  std::string
42  getTitle() const override
43  {
44  return std::string("Eos_A");
45  }
46 
47  std::string
48  getCategory() const override
49  {
50  return std::string("IDL");
51  }
52 
53  std::string
54  getSource() const override
55  {
56  return std::string(
57  "float colormap_h(float x) {\n"
58  " if (x < 0.1151580585723306) {\n"
59  " return (2.25507158009032E+00 * x - 1.17973110308697E+00) * x + "
60  "7.72551618145170E-01; // H1\n"
61  " } else if (x < (9.89643667779019E-01 - 6.61604251019618E-01) / "
62  "(2.80520737708568E+00 - 1.40111938331467E+00)) {\n"
63  " return -2.80520737708568E+00 * x + 9.89643667779019E-01; // H2\n"
64  " } else if (x < (6.61604251019618E-01 - 4.13849520734156E-01) / "
65  "(1.40111938331467E+00 - 7.00489176507247E-01)) {\n"
66  " return -1.40111938331467E+00 * x + 6.61604251019618E-01; // H3\n"
67  " } else if (x < (4.13849520734156E-01 - 2.48319927251200E-01) / "
68  "(7.00489176507247E-01 - 3.49965224045823E-01)) {\n"
69  " return -7.00489176507247E-01 * x + 4.13849520734156E-01; // H4\n"
70  " } else {\n"
71  " return -3.49965224045823E-01 * x + 2.48319927251200E-01; // H5\n"
72  " }\n"
73  "}\n"
74  "\n"
75  "float colormap_v(float x) {\n"
76  " float v = 1.0;\n"
77  " if (x < 0.5) {\n"
78  " v = clamp(2.10566088679245E+00 * x + 7.56360684411500E-01, 0.0, "
79  "1.0);\n"
80  " } else {\n"
81  " v = clamp(-1.70132918347782E+00 * x + 2.20637371757606E+00, 0.0, "
82  "1.0);\n"
83  " }\n"
84  " float period = 4.0 / 105.0;\n"
85  " float len = 3.0 / 252.0;\n"
86  " float t = mod(x + 7.0 / 252.0, period);\n"
87  " if (0.0 <= t && t < len) {\n"
88  " if (x < 0.12) {\n"
89  " v = (1.87862631683169E+00 * x + 6.81498517051705E-01);\n"
90  " } else if (x < 0.73) {\n"
91  " v -= 26.0 / 252.0; \n"
92  " } else {\n"
93  " v = -1.53215278202992E+00 * x + 1.98649818445446E+00;\n"
94  " }\n"
95  " }\n"
96  " return v;\n"
97  "}\n"
98  "\n"
99  "// H1 - H2 = 0\n"
100  "// => [x=-0.8359672286003642,x=0.1151580585723306]\n"
101  "\n"
102  "vec4 colormap_hsv2rgb(float h, float s, float v) {\n"
103  " float r = v;\n"
104  " float g = v;\n"
105  " float b = v;\n"
106  " if (s > 0.0) {\n"
107  " h *= 6.0;\n"
108  " int i = int(h);\n"
109  " float f = h - float(i);\n"
110  " if (i == 1) {\n"
111  " r *= 1.0 - s * f;\n"
112  " b *= 1.0 - s;\n"
113  " } else if (i == 2) {\n"
114  " r *= 1.0 - s;\n"
115  " b *= 1.0 - s * (1.0 - f);\n"
116  " } else if (i == 3) {\n"
117  " r *= 1.0 - s;\n"
118  " g *= 1.0 - s * f;\n"
119  " } else if (i == 4) {\n"
120  " r *= 1.0 - s * (1.0 - f);\n"
121  " g *= 1.0 - s;\n"
122  " } else if (i == 5) {\n"
123  " g *= 1.0 - s;\n"
124  " b *= 1.0 - s * f;\n"
125  " } else {\n"
126  " g *= 1.0 - s * (1.0 - f);\n"
127  " b *= 1.0 - s;\n"
128  " }\n"
129  " }\n"
130  " return vec4(r, g, b, 1.0);\n"
131  "}\n"
132  "\n"
133  "vec4 colormap(float x) {\n"
134  " float h = colormap_h(clamp(x, 0.0, 1.0));\n"
135  " float s = 1.0;\n"
136  " float v = colormap_v(clamp(x, 0.0, 1.0));\n"
137  " return colormap_hsv2rgb(h, s, v);\n"
138  "}\n");
139  }
140  };
141 
142  } // namespace IDL
143 } // namespace colormap
colormap::IDL::EosA::getSource
std::string getSource() const override
Definition: Eos_A.h:54
colormap::Colormap
Definition: colormap.h:17
colormap::IDL::EosA::getColor
Color getColor(double x) const override
Definition: Eos_A.h:29
colormap::Color::g
double g
Definition: colormap.h:14
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
colormap::Colormap::vec4
Definition: colormap.h:33
colormap::IDL::EosA::getTitle
std::string getTitle() const override
Definition: Eos_A.h:42
Color
uint32_t Color
RGBA color.
Definition: color.h:8
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:51
colormap::Color
Definition: colormap.h:12
colormap::IDL::EosA::getCategory
std::string getCategory() const override
Definition: Eos_A.h:48
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:146
min
T min(T t1, T t2)
Definition: gdiam.h:44
colormap::IDL::EosA
Definition: Eos_A.h:13