Volcano.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 Volcano : 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_Volcano.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("Volcano");
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_r1(float x) {\n"
54  " const float pi = 3.141592653589793238462643383279502884197169399;\n"
55  " const float a = 216.6901575438631;\n"
56  " const float b = 1.073972444219095;\n"
57  " const float c = 0.6275803332110022;\n"
58  " const float d = 221.6241814852619;\n"
59  " float v = a * sin(2.0 * pi / b * x + 2.0 * pi * c) + d;\n"
60  " if (v < 0.0) {\n"
61  " return -v;\n"
62  " } else {\n"
63  " return v;\n"
64  " }\n"
65  "}\n"
66  "\n"
67  "float colormap_r2(float x) {\n"
68  " const float pi = 3.141592653589793238462643383279502884197169399;\n"
69  " const float a = 202.3454274460618;\n"
70  " const float b = 1.058678309228987;\n"
71  " const float c = 0.4891299991060677;\n"
72  " const float d = -72.38173481234448;\n"
73  " return a * sin(2.0 * pi / b * x + 2.0 * pi * c) + d;\n"
74  "}\n"
75  "\n"
76  "float colormap_red(float x) {\n"
77  " if (x < 0.4264009656413063) {\n"
78  " return colormap_r1(x);\n"
79  " } else if (x < 0.6024851624202665) {\n"
80  " const float a = (0.0 - 255.0) / (0.6024851624202665 - 0.4264009656413063);\n"
81  " const float b = -0.6024851624202665 * a;\n"
82  " return a * x + b;\n"
83  " } else {\n"
84  " return colormap_r2(x);\n"
85  " }\n"
86  "}\n"
87  "\n"
88  "float colormap_green(float x) {\n"
89  " const float pi = 3.141592653589793238462643383279502884197169399;\n"
90  " const float a = 126.3856859482602;\n"
91  " const float b = 0.6744554815524477;\n"
92  " const float c = 0.01070628027163306;\n"
93  " const float d = 26.95058522613648;\n"
94  " float v = a * sin(2.0 * pi / b * x + 2.0 * pi * c) + d;\n"
95  " if (v < 0.0) {\n"
96  " return -v;\n"
97  " } else {\n"
98  " return v;\n"
99  " }\n"
100  "}\n"
101  "\n"
102  "float colormap_blue(float x) {\n"
103  " const float pi = 3.141592653589793238462643383279502884197169399;\n"
104  " const float a = 126.9540413031656;\n"
105  " const float b = 0.2891013907955124;\n"
106  " const float c = 0.5136633102640619;\n"
107  " const float d = 126.5159759632338;\n"
108  " return a * sin(2.0 * pi / b * x + 2.0 * pi * c) + d;\n"
109  "}\n"
110  "\n"
111  "// R1 - 255 = 0\n"
112  "// => 0.4264009656413063\n"
113  "\n"
114  "// R2 = 0\n"
115  "// => 0.6024851624202665\n"
116  "\n"
117  "vec4 colormap(float x) {\n"
118  " float r = clamp(colormap_red(x) / 255.0, 0.0, 1.0);\n"
119  " float g = clamp(colormap_green(x) / 255.0, 0.0, 1.0);\n"
120  " float b = clamp(colormap_blue(x) / 255.0, 0.0, 1.0);\n"
121  " return vec4(r, g, b, 1.0);\n"
122  "}\n"
123  );
124  }
125  };
126 
127  } // namespace IDL
128 } // namespace colormap
colormap::Colormap
Definition: colormap.h:17
colormap::IDL::Volcano::getColor
Color getColor(double x) const override
Definition: Volcano.h:28
colormap::Color::g
double g
Definition: colormap.h:14
colormap::IDL::Volcano::getCategory
std::string getCategory() const override
Definition: Volcano.h:45
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
colormap::Colormap::vec4
Definition: colormap.h:32
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
This file was automatically created with "create_c++_header.sh".
Definition: colormap.h:9
colormap::Color::r
double r
Definition: colormap.h:14
colormap::IDL::Volcano::getSource
std::string getSource() const override
Definition: Volcano.h:50
colormap::Colormap::WrapperBase
Definition: colormap.h:144
colormap::IDL::Volcano
Definition: Volcano.h:13
min
T min(T t1, T t2)
Definition: gdiam.h:42
colormap::IDL::Volcano::getTitle
std::string getTitle() const override
Definition: Volcano.h:40