apricot.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 transform
11  {
12 
13  class Apricot : 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/transform_apricot.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("apricot");
45  }
46 
47  std::string
48  getCategory() const override
49  {
50  return std::string("transform");
51  }
52 
53  std::string
54  getSource() const override
55  {
56  return std::string(
57  "float colormap_pi = 3.141592653589793;\n"
58  "\n"
59  "float colormap_f(float x, float c) {\n"
60  " return abs((((-5.563e-5 * x + 3.331e-16) * x + 3.045e-1) * x + 4.396e-12) "
61  "* x + c);\n"
62  "}\n"
63  "\n"
64  "float colormap_f2(float x) {\n"
65  " return 262.0 * x + 12.0 * x * sin(((x - 8.0) * x + 66.0 * colormap_pi) * "
66  "x);\n"
67  "}\n"
68  "\n"
69  "float colormap_red(float x) {\n"
70  " if (x < 0.0) {\n"
71  " return 0.0;\n"
72  " } else if (x < 1.0) {\n"
73  " float r = colormap_f2(x);\n"
74  " if (r > 255.0) {\n"
75  " r = 510.0 - r;\n"
76  " }\n"
77  " return r / 255.0;\n"
78  " } else {\n"
79  " return 1.0;\n"
80  " }\n"
81  "}\n"
82  "\n"
83  "\n"
84  "float colormap_green(float x) {\n"
85  " if (x < 0.0) {\n"
86  " return 0.0;\n"
87  " } else if (x < 1.0) {\n"
88  " return (109.0 * x + 25.0 * sin(9.92 * colormap_pi * x) * x) / 255.0;\n"
89  " } else {\n"
90  " return 102.0 / 255.0;\n"
91  " }\n"
92  "}\n"
93  "\n"
94  "float colormap_blue(float x) {\n"
95  " float b = 0.0;\n"
96  " x = x * 256.0;\n"
97  "\n"
98  " if (x < 0.0) {\n"
99  " b = 241.0 / 255.0;\n"
100  " } else if (x < 66.82) {\n"
101  " b = colormap_f(x - 32.0, -27.0);\n"
102  " if (x > 32.0 && b > 225.0) {\n"
103  " b = b - 10.0;\n"
104  " }\n"
105  " } else if (x < 126.67) {\n"
106  " b = colormap_f(x - 97.0, 30.0);\n"
107  " } else if (x < 195.83) {\n"
108  " b = colormap_f(x - 161.0, -27.0);\n"
109  " if (x > 161.0 && b > 225.0) {\n"
110  " b -= 10.0;\n"
111  " }\n"
112  " } else if (x < 256.0) {\n"
113  " b = colormap_f(x - 226.0, 30.0);\n"
114  " } else {\n"
115  " b = 251.0;\n"
116  " }\n"
117  " if (b > 255.0) {\n"
118  " b = 255.0;\n"
119  " }\n"
120  "\n"
121  " return b / 255.0;\n"
122  "}\n"
123  "\n"
124  "vec4 colormap(float x) {\n"
125  " return vec4(colormap_red(x), colormap_green(x), colormap_blue(x), 1.0);\n"
126  "}\n");
127  }
128  };
129 
130  } // namespace transform
131 } // namespace colormap
colormap::transform::Apricot::getColor
Color getColor(double x) const override
Definition: apricot.h:29
colormap::Colormap
Definition: colormap.h:17
colormap::transform::Apricot::getTitle
std::string getTitle() const override
Definition: apricot.h:42
colormap::Color::g
double g
Definition: colormap.h:14
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
colormap::Colormap::vec4
Definition: colormap.h:33
colormap::transform::Apricot
Definition: apricot.h:13
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::transform::Apricot::getCategory
std::string getCategory() const override
Definition: apricot.h:48
armarx::transform
auto transform(const Container< InputT, Alloc > &in, OutputT(*func)(InputT const &)) -> Container< OutputT, typename std::allocator_traits< Alloc >::template rebind_alloc< OutputT >>
Convenience function (with less typing) to transform a container of type InputT into the same contain...
Definition: algorithm.h:351
colormap::Color
Definition: colormap.h:12
colormap::transform::Apricot::getSource
std::string getSource() const override
Definition: apricot.h:54
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
min
T min(T t1, T t2)
Definition: gdiam.h:44