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
8namespace 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
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("Steps");
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 * "
62 "x));\n"
63 " return sign(x) * sqrt(v);\n"
64 "}\n"
65 "\n"
66 "float colormap_red(float x) {\n"
67 " if (x <= 95.5) {\n"
68 " return 8.14475806451613E+00 * x - 5.23967741935484E+02;\n"
69 " } else {\n"
70 " return colormap_erf((x - 145.0) * 0.028) * 131.0 + 125.0;\n"
71 " }\n"
72 "}\n"
73 "\n"
74 "float colormap_green(float x) {\n"
75 " if (x < (3.14410256410256E+02 + 2.14285714285714E-01) / "
76 "(4.25000000000000E+01 + 9.81196581196581E+00)) {\n"
77 " return 4.25000000000000E+01 * x - 2.14285714285714E-01;\n"
78 " } else if (x < 192.0) { // actual root: 193.529143410603\n"
79 " return -9.81196581196581E+00 * x + 3.14410256410256E+02;\n"
80 " } else {\n"
81 " return ((5.35129859215999E-04 * x - 2.98599683017528E-01) * x + "
82 "5.69466901216655E+01) * x - 3.71604038989543E+03;\n"
83 " }\n"
84 "}\n"
85 "\n"
86 "float colormap_blue(float x) {\n"
87 " if (x < 63.0) {\n"
88 " return 8.22620967741936E+00 * x - 2.63729032258065E+02;\n"
89 " } else if (x <= 95.5) {\n"
90 " return 4.97690615835777E+00 * x - 3.16414039589443E+02;\n"
91 " } else {\n"
92 " return (((-7.88871743679920E-05 * x + 7.21525684930384E-02) * x - "
93 "2.45956037640571E+01) * x + 3.70824713134765E+03) * x - "
94 "2.08852518066406E+05;\n"
95 " }\n"
96 "}\n"
97 "\n"
98 "vec4 colormap(float x) {\n"
99 " float t = x * 255.0 - 0.5;\n"
100 " float r = clamp(colormap_red(t) / 255.0, 0.0, 1.0);\n"
101 " float g = clamp(colormap_green(t) / 255.0, 0.0, 1.0);\n"
102 " float b = clamp(colormap_blue(t) / 255.0, 0.0, 1.0);\n"
103 " return vec4(r, g, b, 1.0);\n"
104 "}\n");
105 }
106 };
107
108 } // namespace IDL
109} // namespace colormap
constexpr T c
std::string getCategory() const override
Definition Steps.h:48
std::string getSource() const override
Definition Steps.h:54
Color getColor(double x) const override
Definition Steps.h:29
std::string getTitle() const override
Definition Steps.h:42
uint32_t Color
RGBA color.
Definition color.h:8
This file offers overloads of toIce() and fromIce() functions for STL container types.
This file was automatically created with "create_c++_header.sh".
Definition colormap.h:10