Eos_B.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 EosB : 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_B.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_B");
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.1167535483837128) {\n"
59  " return 2.0 / 3.0; // H1\n"
60  " } else if (x < 0.1767823398113251) {\n"
61  " return ((-3.19659402385354E+02 * x + 1.14469539590179E+02) * x - "
62  "1.52210982227697E+01) * x + 1.39214703883044E+00; // H2\n"
63  " } else if (x < 0.2266354262828827) {\n"
64  " return ((-3.55166097640991E+02 * x + 2.51218596935272E+02) * x - "
65  "6.08853752315044E+01) * x + 5.38727123476564E+00; // H3\n"
66  " } else if (x < (6.95053970124612E-01 - 4.13725796136428E-01) / "
67  "(1.48914458632691E+00 - 6.97458630656247E-01)) {\n"
68  " return -1.48914458632691E+00 * x + 6.95053970124612E-01; // H4\n"
69  " } else if (x < (4.13725796136428E-01 - 2.48329223043123E-01) / "
70  "(6.97458630656247E-01 - 3.48617475202321E-01)) {\n"
71  " return -6.97458630656247E-01 * x + 4.13725796136428E-01; // H5\n"
72  " } else {\n"
73  " return -3.48617475202321E-01 * x + 2.48329223043123E-01; // H6\n"
74  " }\n"
75  "}\n"
76  "\n"
77  "float colormap_v(float x) {\n"
78  " float v = 1.0;\n"
79  " if (x < 0.115834504365921) {\n"
80  " v = 4.18575376272140E+00 * x + 5.15145240089963E-01; // V1-Hi\n"
81  " } else if (x < (1.90980360972022E+00 + 9.13724751363001E-01) / "
82  "(7.87450639585523E+00 + 7.87450803534638E+00)) {\n"
83  " v = -7.87450803534638E+00 * x + 1.90980360972022E+00; // V2-Hi\n"
84  " } else if (x < 0.5) {\n"
85  " v = 7.87450639585523E+00 * x - 9.13724751363001E-01; // V3-Hi\n"
86  " } else {\n"
87  " v = -1.87540494049556E+00 * x + 2.33603077812338E+00; // V4-Hi\n"
88  " }\n"
89  " v = clamp(v, 0.0, 1.0);\n"
90  "\n"
91  " float period = 4.0 / 105.0;\n"
92  " float len = 3.0 / 252.0;\n"
93  " float t = mod(x + 7.0 / 252.0, period);\n"
94  " if (0.0 <= t && t < len) {\n"
95  " if (x < 0.115834504365921) {\n"
96  " v = 3.74113124408467E+00 * x + 4.64654322955584E-01; // "
97  "V1-Lo\n"
98  " } else if (x < (1.90980360972022E+00 + 9.13724751363001E-01) / "
99  "(7.87450639585523E+00 + 7.87450803534638E+00)) {\n"
100  " v = -3.97326878048783E+00 * x + 1.25308500609757E+00; // "
101  "V2-Lo\n"
102  " } else if (x < 0.25) {\n"
103  " v = 6.99297032967038E+00 * x - 8.03946549450558E-01; // "
104  "V3-Lo\n"
105  " } else if (x < 0.72) {\n"
106  " v -= 26.0 / 255.0;\n"
107  " } else {\n"
108  " v = -1.67870020621040E+00 * x + 2.09414636280895E+00; // "
109  "V4-Lo\n"
110  " }\n"
111  " }\n"
112  "\n"
113  " return v;\n"
114  "}\n"
115  "\n"
116  "// H1 - H2 = 0\n"
117  "// => [x=0.1167535483837128]\n"
118  "\n"
119  "// H2 - H3 = 0\n"
120  "// => [x=0.1767823398113251,x=0.1822494566440582,x=3.492328017950058]\n"
121  "\n"
122  "// H3 - H4 = 0\n"
123  "// => [x=0.2266354262828827]\n"
124  "\n"
125  "// V1-Hi - 1 = 0\n"
126  "// => [x=0.115834504365921]\n"
127  "\n"
128  "// V2-Hi - V3-Hi = 0\n"
129  "// => \n"
130  "\n"
131  "vec4 colormap_hsv2rgb(float h, float s, float v) {\n"
132  " float r = v;\n"
133  " float g = v;\n"
134  " float b = v;\n"
135  " if (s > 0.0) {\n"
136  " h *= 6.0;\n"
137  " int i = int(h);\n"
138  " float f = h - float(i);\n"
139  " if (i == 1) {\n"
140  " r *= 1.0 - s * f;\n"
141  " b *= 1.0 - s;\n"
142  " } else if (i == 2) {\n"
143  " r *= 1.0 - s;\n"
144  " b *= 1.0 - s * (1.0 - f);\n"
145  " } else if (i == 3) {\n"
146  " r *= 1.0 - s;\n"
147  " g *= 1.0 - s * f;\n"
148  " } else if (i == 4) {\n"
149  " r *= 1.0 - s * (1.0 - f);\n"
150  " g *= 1.0 - s;\n"
151  " } else if (i == 5) {\n"
152  " g *= 1.0 - s;\n"
153  " b *= 1.0 - s * f;\n"
154  " } else {\n"
155  " g *= 1.0 - s * (1.0 - f);\n"
156  " b *= 1.0 - s;\n"
157  " }\n"
158  " }\n"
159  " return vec4(r, g, b, 1.0);\n"
160  "}\n"
161  "\n"
162  "vec4 colormap(float x) {\n"
163  " float h = colormap_h(clamp(x, 0.0, 1.0));\n"
164  " float s = 1.0;\n"
165  " float v = colormap_v(clamp(x, 0.0, 1.0));\n"
166  " return colormap_hsv2rgb(h, s, v);\n"
167  "}\n");
168  }
169  };
170 
171  } // namespace IDL
172 } // namespace colormap
colormap::Colormap
Definition: colormap.h:17
colormap::IDL::EosB::getTitle
std::string getTitle() const override
Definition: Eos_B.h:42
colormap::IDL::EosB
Definition: Eos_B.h:13
colormap::Color::g
double g
Definition: colormap.h:14
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
colormap::IDL::EosB::getCategory
std::string getCategory() const override
Definition: Eos_B.h:48
colormap::Colormap::vec4
Definition: colormap.h:33
colormap::IDL::EosB::getSource
std::string getSource() const override
Definition: Eos_B.h:54
Color
uint32_t Color
RGBA color.
Definition: color.h:8
colormap::IDL::EosB::getColor
Color getColor(double x) const override
Definition: Eos_B.h:29
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
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