Ocean.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 Ocean : 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_Ocean.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("Ocean");
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_red(float x) {\n"
58 " if (x < 0.84121424085) {\n"
59 " const float pi = 3.141592653589793238462643383279502884197169399;\n"
60 " const float a = 92.39421034238549;\n"
61 " const float b = 88.02925388837211;\n"
62 " const float c = 0.5467741159150409;\n"
63 " const float d = 0.03040219113949284;\n"
64 " return a * sin(2.0 * pi / c * (x - d)) + b;\n"
65 " } else {\n"
66 " return 105.0;\n"
67 " }\n"
68 "}\n"
69 "\n"
70 "float colormap_green(float x) {\n"
71 " if (x < 0.84121424085) {\n"
72 " const float pi = 3.141592653589793238462643383279502884197169399;\n"
73 " const float a = 92.44399971120093;\n"
74 " const float b = 22.7616696017667;\n"
75 " const float c = 0.3971750420482239;\n"
76 " const float d = 0.1428144080827581;\n"
77 " const float e = 203.7220396611977;\n"
78 " const float f = 49.51517183258432;\n"
79 " float v = (a * x + b) * sin(2.0 * pi / c * (x + d)) + (e * x + "
80 "f);\n"
81 " if (v > 255.0) {\n"
82 " return 255.0 - (v - 255.0);\n"
83 " } else {\n"
84 " return v;\n"
85 " }\n"
86 " } else {\n"
87 " return 246.0;\n"
88 " }\n"
89 "}\n"
90 "\n"
91 "float colormap_blue(float x) {\n"
92 " if (x < 0.84121424085) {\n"
93 " const float pi = 3.141592653589793238462643383279502884197169399;\n"
94 " const float a = 251.0868719483008;\n"
95 " const float b = 0.5472498585835275;\n"
96 " const float c = 0.02985857858149428;\n"
97 " const float d = 225.9495771701237;\n"
98 " float v = a * sin(2.0 * pi / b * (x - c)) + d;\n"
99 " if (v > 255.0) {\n"
100 " return 255.0 - (v - 255.0);\n"
101 " } else if (v < 0.0) {\n"
102 " return -v;\n"
103 " } else {\n"
104 " return v;\n"
105 " }\n"
106 " } else {\n"
107 " return 234.0;\n"
108 " }\n"
109 "}\n"
110 "\n"
111 "// R1 - 105 = 0\n"
112 "// => 0.8344881408181015\n"
113 "\n"
114 "// B1 - 234 = 0\n"
115 "// => 0.847940340889657\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 } // namespace IDL
127} // namespace colormap
constexpr T c
std::string getCategory() const override
Definition Ocean.h:48
std::string getSource() const override
Definition Ocean.h:54
Color getColor(double x) const override
Definition Ocean.h:29
std::string getTitle() const override
Definition Ocean.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