Hue_Sat_Value_1.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 HueSatValue1 : 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_1.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_1");
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 (3.31549320112257E-06 * x + 9.90093135228017E-01) * x - 2.85569629002368E-01;\n"
55  "}\n"
56  "\n"
57  "float colormap_r2(float x) {\n"
58  " float t = x - 172.2021990097892;\n"
59  " return (-2.39029325463818E-02 * t + 2.98715296752437E+00) * t + 170.308961782;\n"
60  "}\n"
61  "\n"
62  "float colormap_g1(float x) {\n"
63  " float t = x - 86.01791713538523;\n"
64  " return (-2.29102048531908E-02 * t + 4.93089581616270E+00) * t + 84.9047112396;\n"
65  "}\n"
66  "\n"
67  "float colormap_g2(float x) {\n"
68  " float t = x - 215.6804047700857;\n"
69  " return ((-2.84214232291614E-04 * t + 3.97502254733824E-02) * t - 1.21659773743153E+00) * t + 255.0;\n"
70  "}\n"
71  "\n"
72  "float colormap_b2(float x) {\n"
73  " float t = x - 129.1625547389263;\n"
74  " return (2.47358957372179E-02 * t - 3.03236899995258E+00) * t + 255.0;\n"
75  "}\n"
76  "\n"
77  "float colormap_red(float x) {\n"
78  " if (x < 43.15291462916737) {\n"
79  " return 255.0;\n"
80  " } else if (x < 86.01791713538523) {\n"
81  " return (2.31649880284905E-02 * x - 6.92920742890475E+00) * x + 5.09541054138852E+02; // R1\n"
82  " } else if (x < 172.2021990097892) {\n"
83  " return colormap_low(x);\n"
84  " } else if (x < 215.6804047700857) {\n"
85  " return colormap_r2(x);\n"
86  " } else {\n"
87  " return 255.0;\n"
88  " }\n"
89  "}\n"
90  "\n"
91  "float colormap_green(float x) {\n"
92  " if (x < 86.01791713538523) {\n"
93  " return colormap_low(x);\n"
94  " } else if (x < 129.1625547389263) {\n"
95  " return colormap_g1(x);\n"
96  " } else if (x < 215.6804047700857) {\n"
97  " return 255.0;\n"
98  " } else {\n"
99  " return colormap_g2(x);\n"
100  " }\n"
101  "}\n"
102  "\n"
103  "float colormap_blue(float x) {\n"
104  " if (x < 43.15291462916737) {\n"
105  " return (-2.29056417125175E-02 * x + 6.89833449327894E+00) * x - 2.89480825884616E-02; // B1\n"
106  " } else if (x < 129.1625547389263) {\n"
107  " return 255.0;\n"
108  " } else if (x < 172.2021990097892) {\n"
109  " return colormap_b2(x);\n"
110  " } else {\n"
111  " return colormap_low(x);\n"
112  " }\n"
113  "}\n"
114  "\n"
115  "// B1 - 255 = 0\n"
116  "// => [x=43.15291462916737,x=258.0102040408121]\n"
117  "\n"
118  "// R1 - low = 0\n"
119  "// => [x=86.01791713538523,x=255.8961027639475]\n"
120  "\n"
121  "// G1 - 255 = 0\n"
122  "// => [x=129.1625547389263,x=258.1003299995292]\n"
123  "\n"
124  "// B2 - low = 0\n"
125  "// => [x=172.2021990097892,x=248.7957319298701]\n"
126  "\n"
127  "// R2 - 255 = 0\n"
128  "// => [x=215.6804047700857,x=253.6941391396688]\n"
129  "\n"
130  "// low(86.01791713538523) = 84.9047112396\n"
131  "// low(172.2021990097892) = 170.308961782\n"
132  "\n"
133  "vec4 colormap(float x) {\n"
134  " float t = x * 255.0;\n"
135  " float r = clamp(colormap_red(t) / 255.0, 0.0, 1.0);\n"
136  " float g = clamp(colormap_green(t) / 255.0, 0.0, 1.0);\n"
137  " float b = clamp(colormap_blue(t) / 255.0, 0.0, 1.0);\n"
138  " return vec4(r, g, b, 1.0);\n"
139  "}\n"
140  );
141  }
142  };
143 
144  } // namespace IDL
145 } // 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::Colormap::vec4
Definition: colormap.h:32
colormap::IDL::HueSatValue1::getCategory
std::string getCategory() const override
Definition: Hue_Sat_Value_1.h:45
colormap::Color::a
double a
Definition: colormap.h:14
colormap::IDL::HueSatValue1::getColor
Color getColor(double x) const override
Definition: Hue_Sat_Value_1.h:28
colormap::IDL::HueSatValue1
Definition: Hue_Sat_Value_1.h:13
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
colormap::IDL::HueSatValue1::getTitle
std::string getTitle() const override
Definition: Hue_Sat_Value_1.h:40
colormap::IDL::HueSatValue1::getSource
std::string getSource() const override
Definition: Hue_Sat_Value_1.h:50