Steps.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 Steps : 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_Steps.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("Steps");
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_erf(float x) {\n"
54  " // erf approximation formula\n"
55  " const float pi = 3.141592653589793238462643383279502884197169399;\n"
56  " const float a = -8.0 * (pi - 3.0) / (3.0 * pi * (pi - 4.0));\n"
57  " float v = 1.0 - exp(-x * x * (4.0 / pi + a * x * x) / (1.0 + a * x * x));\n"
58  " return sign(x) * sqrt(v);\n"
59  "}\n"
60  "\n"
61  "float colormap_red(float x) {\n"
62  " if (x <= 95.5) {\n"
63  " return 8.14475806451613E+00 * x - 5.23967741935484E+02;\n"
64  " } else {\n"
65  " return colormap_erf((x - 145.0) * 0.028) * 131.0 + 125.0;\n"
66  " }\n"
67  "}\n"
68  "\n"
69  "float colormap_green(float x) {\n"
70  " if (x < (3.14410256410256E+02 + 2.14285714285714E-01) / (4.25000000000000E+01 + 9.81196581196581E+00)) {\n"
71  " return 4.25000000000000E+01 * x - 2.14285714285714E-01;\n"
72  " } else if (x < 192.0) { // actual root: 193.529143410603\n"
73  " return -9.81196581196581E+00 * x + 3.14410256410256E+02;\n"
74  " } else {\n"
75  " return ((5.35129859215999E-04 * x - 2.98599683017528E-01) * x + 5.69466901216655E+01) * x - 3.71604038989543E+03;\n"
76  " }\n"
77  "}\n"
78  "\n"
79  "float colormap_blue(float x) {\n"
80  " if (x < 63.0) {\n"
81  " return 8.22620967741936E+00 * x - 2.63729032258065E+02;\n"
82  " } else if (x <= 95.5) {\n"
83  " return 4.97690615835777E+00 * x - 3.16414039589443E+02;\n"
84  " } else {\n"
85  " return (((-7.88871743679920E-05 * x + 7.21525684930384E-02) * x - 2.45956037640571E+01) * x + 3.70824713134765E+03) * x - 2.08852518066406E+05;\n"
86  " }\n"
87  "}\n"
88  "\n"
89  "vec4 colormap(float x) {\n"
90  " float t = x * 255.0 - 0.5;\n"
91  " float r = clamp(colormap_red(t) / 255.0, 0.0, 1.0);\n"
92  " float g = clamp(colormap_green(t) / 255.0, 0.0, 1.0);\n"
93  " float b = clamp(colormap_blue(t) / 255.0, 0.0, 1.0);\n"
94  " return vec4(r, g, b, 1.0);\n"
95  "}\n"
96  );
97  }
98  };
99 
100  } // namespace IDL
101 } // 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::Colormap::vec4
Definition: colormap.h:32
colormap::IDL::Steps::getCategory
std::string getCategory() const override
Definition: Steps.h:45
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::IDL::Steps::getColor
Color getColor(double x) const override
Definition: Steps.h:28
colormap::IDL::Steps::getTitle
std::string getTitle() const override
Definition: Steps.h:40
colormap::Color
Definition: colormap.h:12
colormap
This file was automatically created with "create_c++_header.sh".
Definition: colormap.h:9
colormap::IDL::Steps::getSource
std::string getSource() const override
Definition: Steps.h:50
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::Steps
Definition: Steps.h:13