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