Purple-Red+Stripes.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
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_Purple-Red+Stripes.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("Purple-Red+Stripes");
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_h(float x) {\n"
58 " if (x < 0.3310005332481092) {\n"
59 " return (4.38091557495284E-01 * x - 6.45518032448820E-01) * x + "
60 "8.32595065985926E-01; // H1\n"
61 " } else if (x < 0.836653386) {\n"
62 " return -9.95987681712782E-01 * x + 9.96092924041492E-01; // H2\n"
63 " } else if (x < 0.9144920256360881) {\n"
64 " return (-3.25656183098909E+00 * x + 4.39104086393490E+00) * x - "
65 "1.23205476222211E+00; // H3\n"
66 " } else {\n"
67 " return (1.68724608409684E+00 * x - 3.93349028637749E+00) * x + "
68 "2.24617746415606E+00; // H4\n"
69 " }\n"
70 "}\n"
71 "\n"
72 "float colormap_s(float x) {\n"
73 " if (x < 0.9124516770628384) {\n"
74 " return -2.49531958245657E+00 * x + 3.07915192631601E+00; // S1\n"
75 " } else {\n"
76 " return 2.28056601637550E+00 * x - 1.27861289779857E+00; // S2\n"
77 " }\n"
78 "}\n"
79 "\n"
80 "float colormap_v(float x) {\n"
81 " float v = clamp(7.55217853407034E-01 * x + 7.48186662435193E-01, 0.0, "
82 "1.0);\n"
83 " float period = 0.039840637;\n"
84 " float t = x - 0.027888446;\n"
85 " float tt = t - float(int(t / period)) * period;\n"
86 " if (0.0 <= tt && tt < 0.007968127) {\n"
87 " v -= 0.2;\n"
88 " }\n"
89 " return v;\n"
90 "}\n"
91 "\n"
92 "// H1 - H2 = 0\n"
93 "// => [x=-1.186402343934078,x=0.3310005332481092]\n"
94 "\n"
95 "// H3 - H4 = 0\n"
96 "// => [x=0.7693377859773962,x=0.9144920256360881]\n"
97 "\n"
98 "// S1 - 1 = 0\n"
99 "// => [x=0.9124516770628384]\n"
100 "\n"
101 "vec4 colormap_hsv2rgb(float h, float s, float v) {\n"
102 " float r = v;\n"
103 " float g = v;\n"
104 " float b = v;\n"
105 " if (s > 0.0) {\n"
106 " h *= 6.0;\n"
107 " int i = int(h);\n"
108 " float f = h - float(i);\n"
109 " if (i == 1) {\n"
110 " r *= 1.0 - s * f;\n"
111 " b *= 1.0 - s;\n"
112 " } else if (i == 2) {\n"
113 " r *= 1.0 - s;\n"
114 " b *= 1.0 - s * (1.0 - f);\n"
115 " } else if (i == 3) {\n"
116 " r *= 1.0 - s;\n"
117 " g *= 1.0 - s * f;\n"
118 " } else if (i == 4) {\n"
119 " r *= 1.0 - s * (1.0 - f);\n"
120 " g *= 1.0 - s;\n"
121 " } else if (i == 5) {\n"
122 " g *= 1.0 - s;\n"
123 " b *= 1.0 - s * f;\n"
124 " } else {\n"
125 " g *= 1.0 - s * (1.0 - f);\n"
126 " b *= 1.0 - s;\n"
127 " }\n"
128 " }\n"
129 " return vec4(r, g, b, 1.0);\n"
130 "}\n"
131 "\n"
132 "vec4 colormap(float x) {\n"
133 " float h = colormap_h(clamp(x, 0.0, 1.0));\n"
134 " float s = colormap_s(clamp(x, 0.0, 1.0));\n"
135 " float v = colormap_v(clamp(x, 0.0, 1.0));\n"
136 " return colormap_hsv2rgb(h, s, v);\n"
137 "}\n");
138 }
139 };
140
141 } // namespace IDL
142} // namespace colormap
constexpr T c
std::string getCategory() const override
std::string getSource() const override
Color getColor(double x) const override
std::string getTitle() const override
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