Hue_Sat_Value_2.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 HueSatValue2 : 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_Hue_Sat_Value_2.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("Hue_Sat_Value_2");
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_low(float x) {\n"
54  " return -9.89123311722871E-01 * x + 2.54113856910082E+02;\n"
55  "}\n"
56  "\n"
57  "float colormap_r1(float x) {\n"
58  " float t = x - 44.52807774916808;\n"
59  " return (-2.10743035084859E-02 * t - 1.14339819510944E+00) * t + 255.0;\n"
60  "}\n"
61  "\n"
62  "float colormap_r2(float x) {\n"
63  " float t = x - 173.2142990353825;\n"
64  " return (2.10464655909683E-02 * t + 3.09770350177039E+00) * t + 82.7835558104;\n"
65  "}\n"
66  "\n"
67  "float colormap_g1(float x) {\n"
68  " float t = x - 87.18599073927922;\n"
69  " return (2.18814766236433E-02 * t + 1.07683877405025E+00) * t + 167.876161014;\n"
70  "}\n"
71  "\n"
72  "float colormap_g2(float x) {\n"
73  " float t = x - 216.2347301863598;\n"
74  " return (-1.75617661106684E-02 * t - 5.19390917463437E+00) * t + 255.0;\n"
75  "}\n"
76  "\n"
77  "float colormap_b2(float x) {\n"
78  " float t = x - 130.3078696041572;\n"
79  " return (-1.97675474706200E-02 * t - 3.16561290370380E+00) * t + 255.0;\n"
80  "}\n"
81  "\n"
82  "float colormap_red(float x) {\n"
83  " if (x < 44.52807774916808) {\n"
84  " return 255.0;\n"
85  " } else if (x < 87.18599073927922) {\n"
86  " return colormap_r1(x);\n"
87  " } else if (x < 173.2142990353825) {\n"
88  " return colormap_low(x);\n"
89  " } else if (x < 216.2347301863598) {\n"
90  " return colormap_r2(x);\n"
91  " } else {\n"
92  " return 255.0;\n"
93  " }\n"
94  "}\n"
95  "\n"
96  "float colormap_green(float x) {\n"
97  " if (x < 87.18599073927922) {\n"
98  " return colormap_low(x);\n"
99  " } else if (x < 130.3078696041572) {\n"
100  " return colormap_g1(x);\n"
101  " } else if (x < 216.2347301863598) {\n"
102  " return 255.0;\n"
103  " } else {\n"
104  " return colormap_g2(x);\n"
105  " }\n"
106  "}\n"
107  "\n"
108  "float colormap_blue(float x) {\n"
109  " if (x < 44.52807774916808) {\n"
110  " return (2.31958376441286E-02 * x - 1.01298265446011E+00) * x + 2.54114630079813E+02; // B1\n"
111  " } else if (x < 130.3078696041572) {\n"
112  " return 255.0;\n"
113  " } else if (x < 173.2142990353825) {\n"
114  " return colormap_b2(x);\n"
115  " } else {\n"
116  " return colormap_low(x);\n"
117  " }\n"
118  "}\n"
119  "\n"
120  "// B1 - 255 = 0\n"
121  "// => [x=-0.8571972230440585,x=44.52807774916808]\n"
122  "\n"
123  "// R1 - low = 0\n"
124  "// => [x=-5.450356335481052,x=87.18599073927922]\n"
125  "\n"
126  "// G1 - 255 = 0\n"
127  "// => [x=-5.148233003947013,x=130.3078696041572]\n"
128  "\n"
129  "// B2 - low = 0\n"
130  "// => [x=-22.70273917535556,x=173.2142990353825]\n"
131  "\n"
132  "// R2 - 255 = 0\n"
133  "// => [x=-16.99015635858727,x=216.2347301863598]\n"
134  "\n"
135  "// low(87.18599073927922) = 167.876161014\n"
136  "// low(173.2142990353825) = 82.7835558104\n"
137  "\n"
138  "vec4 colormap(float x) {\n"
139  " float t = x * 255.0;\n"
140  " float r = clamp(colormap_red(t) / 255.0, 0.0, 1.0);\n"
141  " float g = clamp(colormap_green(t) / 255.0, 0.0, 1.0);\n"
142  " float b = clamp(colormap_blue(t) / 255.0, 0.0, 1.0);\n"
143  " return vec4(r, g, b, 1.0);\n"
144  "}\n"
145  );
146  }
147  };
148 
149  } // namespace IDL
150 } // 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::IDL::HueSatValue2::getSource
std::string getSource() const override
Definition: Hue_Sat_Value_2.h:50
colormap::Colormap::vec4
Definition: colormap.h:32
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::HueSatValue2::getTitle
std::string getTitle() const override
Definition: Hue_Sat_Value_2.h:40
colormap::IDL::HueSatValue2
Definition: Hue_Sat_Value_2.h:13
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::IDL::HueSatValue2::getCategory
std::string getCategory() const override
Definition: Hue_Sat_Value_2.h:45
colormap::Colormap::WrapperBase
Definition: colormap.h:144
colormap::IDL::HueSatValue2::getColor
Color getColor(double x) const override
Definition: Hue_Sat_Value_2.h:28
min
T min(T t1, T t2)
Definition: gdiam.h:42