Hue_Sat_Lightness_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 HueSatLightness1 : 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_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_Lightness_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 (-1.91005335917480E-03 * x + 1.49751468348116E+00) * x - "
59  "6.97037614414503E+00; // lower\n"
60  "}\n"
61  "\n"
62  "float colormap_up(float x) {\n"
63  " return (1.88420526249161E-03 * x - 5.03556849093925E-01) * x + "
64  "2.55777688663313E+02; // upper\n"
65  "}\n"
66  "\n"
67  "float colormap_red(float x) {\n"
68  " if (x < 43.76015739302458) { // first root of `lower = B1`\n"
69  " return colormap_up(x);\n"
70  " } else if (x < 86.85552651930304) { // first root of `lower = R1`\n"
71  " return (3.42882679808412E-02 * x - 7.47424573913507E+00) * x + "
72  "4.99200716753466E+02; // R1\n"
73  " } else if (x < 174.6136813850324) { // first root of `low = B2`\n"
74  " return colormap_low(x);\n"
75  " } else {\n"
76  " return ((1.12237347384081E-04 * x - 7.83534162528667E-02) * x + "
77  "1.86033275155350E+01) * x - 1.25879271751642E+03;\n"
78  " }\n"
79  "}\n"
80  "\n"
81  "float colormap_green(float x) {\n"
82  " if (x < 86.85552651930304) {\n"
83  " return colormap_low(x);\n"
84  " } else if (x < 130.6514942376722) {\n"
85  " return (-2.86318899478317E-02 * x + 8.83599571161434E+00) * x - "
86  "4.43544771805581E+02; // G1\n"
87  " } else {\n"
88  " return colormap_up(x);\n"
89  " }\n"
90  "}\n"
91  "\n"
92  "float colormap_blue(float x) {\n"
93  " if (x < 43.76015739302458) {\n"
94  " return (-3.50205069618621E-02 * x + 7.15746326474339E+00) * x - "
95  "8.79902788903102E+00; // B1\n"
96  " } else if (x < 130.6514942376722) { // first root of `upper = G1`\n"
97  " return colormap_up(x);\n"
98  " } else if (x < 174.6136813850324) { // first root of `low = B2`\n"
99  " return (1.99506804131033E-02 * x - 6.64847464240324E+00) * x + "
100  "7.48898397192062E+02; // B2\n"
101  " } else {\n"
102  " return colormap_low(x);\n"
103  " }\n"
104  "}\n"
105  "\n"
106  "vec4 colormap(float x) {\n"
107  " float t = x * 255.0;\n"
108  " float r = clamp(colormap_red(t) / 255.0, 0.0, 1.0);\n"
109  " float g = clamp(colormap_green(t) / 255.0, 0.0, 1.0);\n"
110  " float b = clamp(colormap_blue(t) / 255.0, 0.0, 1.0);\n"
111  " return vec4(r, g, b, 1.0);\n"
112  "}\n");
113  }
114  };
115 
116  } // namespace IDL
117 } // namespace colormap
colormap::Colormap
Definition: colormap.h:17
colormap::IDL::HueSatLightness1::getSource
std::string getSource() const override
Definition: Hue_Sat_Lightness_1.h:54
colormap::IDL::HueSatLightness1
Definition: Hue_Sat_Lightness_1.h:13
colormap::IDL::HueSatLightness1::getColor
Color getColor(double x) const override
Definition: Hue_Sat_Lightness_1.h:29
colormap::Color::g
double g
Definition: colormap.h:14
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
colormap::Colormap::vec4
Definition: colormap.h:33
Color
uint32_t Color
RGBA color.
Definition: color.h:8
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:51
colormap::Color
Definition: colormap.h:12
colormap::IDL::HueSatLightness1::getCategory
std::string getCategory() const override
Definition: Hue_Sat_Lightness_1.h:48
colormap::IDL::HueSatLightness1::getTitle
std::string getTitle() const override
Definition: Hue_Sat_Lightness_1.h:42
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