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