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