CB-Spectral.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 CBSpectral : 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_CB-Spectral.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("CB-Spectral");
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_red(float x) {\n"
54  " if (x < 0.09752005946586478) {\n"
55  " return 5.63203907203907E+02 * x + 1.57952380952381E+02;\n"
56  " } else if (x < 0.2005235116443438) {\n"
57  " return 3.02650769230760E+02 * x + 1.83361538461540E+02;\n"
58  " } else if (x < 0.2974133397506856) {\n"
59  " return 9.21045429665647E+01 * x + 2.25581007115501E+02;\n"
60  " } else if (x < 0.5003919130598823) {\n"
61  " return 9.84288115246108E+00 * x + 2.50046722689075E+02;\n"
62  " } else if (x < 0.5989021956920624) {\n"
63  " return -2.48619704433547E+02 * x + 3.79379310344861E+02;\n"
64  " } else if (x < 0.902860552072525) {\n"
65  " return ((2.76764884219295E+03 * x - 6.08393126459837E+03) * x + 3.80008072407485E+03) * x - 4.57725185424742E+02;\n"
66  " } else {\n"
67  " return 4.27603478260530E+02 * x - 3.35293188405479E+02;\n"
68  " }\n"
69  "}\n"
70  "\n"
71  "float colormap_green(float x) {\n"
72  " if (x < 0.09785836420571035) {\n"
73  " return 6.23754529914529E+02 * x + 7.26495726495790E-01;\n"
74  " } else if (x < 0.2034012006283468) {\n"
75  " return 4.60453201970444E+02 * x + 1.67068965517242E+01;\n"
76  " } else if (x < 0.302409765476316) {\n"
77  " return 6.61789401709441E+02 * x - 2.42451282051364E+01;\n"
78  " } else if (x < 0.4005965758690823) {\n"
79  " return 4.82379130434784E+02 * x + 3.00102898550747E+01;\n"
80  " } else if (x < 0.4981907026473237) {\n"
81  " return 3.24710622710631E+02 * x + 9.31717541717582E+01;\n"
82  " } else if (x < 0.6064345916502067) {\n"
83  " return -9.64699507389807E+01 * x + 3.03000000000023E+02;\n"
84  " } else if (x < 0.7987472620841592) {\n"
85  " return -2.54022986425337E+02 * x + 3.98545610859729E+02;\n"
86  " } else {\n"
87  " return -5.71281628959223E+02 * x + 6.51955082956207E+02;\n"
88  " }\n"
89  "}\n"
90  "\n"
91  "float colormap_blue(float x) {\n"
92  " if (x < 0.0997359608740309) {\n"
93  " return 1.26522393162393E+02 * x + 6.65042735042735E+01;\n"
94  " } else if (x < 0.1983790695667267) {\n"
95  " return -1.22037851037851E+02 * x + 9.12946682946686E+01;\n"
96  " } else if (x < 0.4997643530368805) {\n"
97  " return (5.39336225400169E+02 * x + 3.55461986381562E+01) * x + 3.88081126069087E+01;\n"
98  " } else if (x < 0.6025972254407099) {\n"
99  " return -3.79294261294313E+02 * x + 3.80837606837633E+02;\n"
100  " } else if (x < 0.6990141388105746) {\n"
101  " return 1.15990231990252E+02 * x + 8.23805453805459E+01;\n"
102  " } else if (x < 0.8032653181119567) {\n"
103  " return 1.68464957265204E+01 * x + 1.51683418803401E+02;\n"
104  " } else if (x < 0.9035796343050095) {\n"
105  " return 2.40199023199020E+02 * x - 2.77279202279061E+01;\n"
106  " } else {\n"
107  " return -2.78813846153774E+02 * x + 4.41241538461485E+02;\n"
108  " }\n"
109  "}\n"
110  "\n"
111  "vec4 colormap(float x) {\n"
112  " float r = clamp(colormap_red(x) / 255.0, 0.0, 1.0);\n"
113  " float g = clamp(colormap_green(x) / 255.0, 0.0, 1.0);\n"
114  " float b = clamp(colormap_blue(x) / 255.0, 0.0, 1.0);\n"
115  " return vec4(r, g, b, 1.0);\n"
116  "}\n"
117  );
118  }
119  };
120 
121  } // namespace IDL
122 } // namespace colormap
colormap::Colormap
Definition: colormap.h:17
colormap::IDL::CBSpectral::getCategory
std::string getCategory() const override
Definition: CB-Spectral.h:45
colormap::IDL::CBSpectral
Definition: CB-Spectral.h:13
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::CBSpectral::getSource
std::string getSource() const override
Definition: CB-Spectral.h:50
colormap::IDL::CBSpectral::getColor
Color getColor(double x) const override
Definition: CB-Spectral.h:28
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::CBSpectral::getTitle
std::string getTitle() const override
Definition: CB-Spectral.h:40
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