CB-OrRd.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 CBOrRd : 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-OrRd.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("CB-OrRd");
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_erf(float x) {\n"
58  " // erf approximation formula\n"
59  " const float pi = 3.141592653589793238462643383279502884197169399;\n"
60  " const float a = -8.0 * (pi - 3.0) / (3.0 * pi * (pi - 4.0));\n"
61  " float v = 1.0 - exp(-x * x * (4.0 / pi + a * x * x) / (1.0 + a * x * x));\n"
62  " return sign(x) * sqrt(v);\n"
63  "}\n"
64  "\n"
65  "float colormap_red(float x) {\n"
66  " return 127.0548665301906 * (1.0 - colormap_erf(2.926357498911938 * (x - "
67  "1.0)));\n"
68  "}\n"
69  "\n"
70  "float colormap_green(float x) {\n"
71  " if (x < 0.3619403852314316) {\n"
72  " return (-1.54198428391755E+02 * x - 1.02444772146395E+02) * x + "
73  "2.46537152765234E+02;\n"
74  " } else {\n"
75  " return (-9.36243338922068E+01 * x - 2.52981049073614E+02) * x + "
76  "2.93087053416795E+02;\n"
77  " }\n"
78  "}\n"
79  "\n"
80  "float colormap_blue(float x) {\n"
81  " if (x < 0.257177186368595) {\n"
82  " return -3.12872659968267E+02 * x + 2.36904283447911E+02;\n"
83  " } else if (x < 0.3782584246092673) {\n"
84  " return -2.10348217636022E+02 * x + 2.10537335834895E+02;\n"
85  " } else if (x < 0.4977365973504272) {\n"
86  " return -3.49969458128060E+02 * x + 2.63350246305405E+02;\n"
87  " } else if (x < 0.6243924786616242) {\n"
88  " return -1.32763025210105E+02 * x + 1.55238655462198E+02;\n"
89  " } else if (x < 0.7554357868699768) {\n"
90  " return -3.23593609804140E+02 * x + 2.74391837181314E+02;\n"
91  " } else {\n"
92  " return -2.41701581027554E+02 * x + 2.12527667984095E+02;\n"
93  " }\n"
94  "}\n"
95  "\n"
96  "vec4 colormap(float x) {\n"
97  " float r = clamp(colormap_red(x) / 255.0, 0.0, 1.0);\n"
98  " float g = clamp(colormap_green(x) / 255.0, 0.0, 1.0);\n"
99  " float b = clamp(colormap_blue(x) / 255.0, 0.0, 1.0);\n"
100  " return vec4(r, g, b, 1.0);\n"
101  "}\n");
102  }
103  };
104 
105  } // namespace IDL
106 } // namespace colormap
colormap::Colormap
Definition: colormap.h:17
colormap::Color::g
double g
Definition: colormap.h:14
colormap::IDL::CBOrRd::getTitle
std::string getTitle() const override
Definition: CB-OrRd.h:42
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::IDL::CBOrRd
Definition: CB-OrRd.h:13
colormap::Color::a
double a
Definition: colormap.h:14
colormap::IDL::CBOrRd::getColor
Color getColor(double x) const override
Definition: CB-OrRd.h:29
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::CBOrRd::getCategory
std::string getCategory() const override
Definition: CB-OrRd.h:48
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
colormap::IDL::CBOrRd::getSource
std::string getSource() const override
Definition: CB-OrRd.h:54
min
T min(T t1, T t2)
Definition: gdiam.h:44