Hue_Sat_Lightness_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 HueSatLightness2 : 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_Lightness_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_Lightness_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_up(float x) {\n"
54  " return (1.88200166286601E-03 * x - 4.65545143706978E-01) * x + 2.51008231568770E+02;\n"
55  "}\n"
56  "\n"
57  "float colormap_low(float x) {\n"
58  " return (-1.90879354636631E-03 * x - 5.05775136749144E-01) * x + 2.51839633472648E+02;\n"
59  "}\n"
60  "\n"
61  "float colormap_r1(float x) {\n"
62  " float t = x - 84.41170691108532;\n"
63  " return ((-1.30664056487685E-04 * t - 2.23609578814399E-02) * t - 1.63427831229829E+00) * t + colormap_low(84.41170691108532);\n"
64  "}\n"
65  "\n"
66  "float colormap_r2(float x) {\n"
67  " float t = (x - 172.4679464259528);\n"
68  " return (3.39051205856669E-02 * t + 1.53777364753859E+00) * t + colormap_low(172.4679464259528);\n"
69  "}\n"
70  "\n"
71  "float colormap_g1(float x) {\n"
72  " return (2.06966753567031E-02 * x - 3.81765550976615E+00) * x + 3.70329541512642E+02;\n"
73  "}\n"
74  "\n"
75  "float colormap_g2(float x) {\n"
76  " float t = x - 215.8140719563986;\n"
77  " return (-2.93369381849802E-02 * t - 4.45609461245051E+00) * t + colormap_up(215.8140719563986);\n"
78  "}\n"
79  "\n"
80  "float colormap_b1(float x) {\n"
81  " float t = (x - 129.0039558892991);\n"
82  " return (-2.69029805601284E-02 * t - 1.46365429919324E+00) * t + colormap_up(129.0039558892991);\n"
83  "}\n"
84  "\n"
85  "float colormap_red(float x) {\n"
86  " if (x < 84.41170691108532) {\n"
87  " return colormap_r1(x);\n"
88  " } else if (x < 172.4679464259528) {\n"
89  " return colormap_low(x);\n"
90  " } else if (x < 215.8140719563986) {\n"
91  " return colormap_r2(x);\n"
92  " } else {\n"
93  " return colormap_up(x);\n"
94  " }\n"
95  "}\n"
96  "\n"
97  "float colormap_green(float x) {\n"
98  " if (x < 84.41170691108532) {\n"
99  " return colormap_low(x);\n"
100  " } else if (x < 129.0039558892991) {\n"
101  " return colormap_g1(x);\n"
102  " } else if (x < 215.8140719563986) {\n"
103  " return colormap_up(x);\n"
104  " } else {\n"
105  " return colormap_g2(x);\n"
106  " }\n"
107  "}\n"
108  "\n"
109  "float colormap_blue(float x) {\n"
110  " if (x < 129.0039558892991) {\n"
111  " return colormap_up(x);\n"
112  " } else if (x < 172.4679464259528) {\n"
113  " return colormap_b1(x);\n"
114  " } else {\n"
115  " return colormap_low(x);\n"
116  " }\n"
117  "}\n"
118  "\n"
119  "// G1 = low\n"
120  "// => [x=62.09621943267293,x=84.41170691108532]\n"
121  "\n"
122  "// G1 = up\n"
123  "// => [x=49.16072666680554,x=129.0039558892991]\n"
124  "\n"
125  "// B1 = low\n"
126  "// => [x=66.91982278615977,x=172.4679464259528]\n"
127  "\n"
128  "// R2 = up\n"
129  "// => [x=86.8352194379599,x=215.8140719563986]\n"
130  "\n"
131  "// low(172.4679464259528) = 107.83220272\n"
132  "// up(215.8140719563986) = 238.192608973\n"
133  "\n"
134  "vec4 colormap(float x) {\n"
135  " float t = x * 255.0;\n"
136  " float r = clamp(colormap_red(t) / 255.0, 0.0, 1.0);\n"
137  " float g = clamp(colormap_green(t) / 255.0, 0.0, 1.0);\n"
138  " float b = clamp(colormap_blue(t) / 255.0, 0.0, 1.0);\n"
139  " return vec4(r, g, b, 1.0);\n"
140  "}\n"
141  );
142  }
143  };
144 
145  } // namespace IDL
146 } // 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::HueSatLightness2::getCategory
std::string getCategory() const override
Definition: Hue_Sat_Lightness_2.h:45
colormap::Colormap::vec4
Definition: colormap.h:32
colormap::IDL::HueSatLightness2
Definition: Hue_Sat_Lightness_2.h:13
colormap::Color::a
double a
Definition: colormap.h:14
colormap::IDL::HueSatLightness2::getSource
std::string getSource() const override
Definition: Hue_Sat_Lightness_2.h:50
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::HueSatLightness2::getTitle
std::string getTitle() const override
Definition: Hue_Sat_Lightness_2.h:40
colormap::IDL::HueSatLightness2::getColor
Color getColor(double x) const override
Definition: Hue_Sat_Lightness_2.h:28