FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
Color.hpp
1#ifndef __FIBER_FIELD_COLOR_HPP
2#define __FIBER_FIELD_COLOR_HPP
3
4#include "FiberType.hpp"
5#include <eagle/ColorSpace.hpp>
6
7namespace Fiber
8{
9
10inline unsigned char clamp_int_to_byte(int i)
11{
12 if (i<0) return 0;
13 if (i>255) return 255;
14 return i;
15}
16
17
18inline unsigned char clamp_flt_to_byte(double d)
19{
20 if (d<=0) return 0;
21 if (d>=1.0) return 255;
22 return int(d*255);
23}
24
25
26 typedef Eagle::rgb_t rgb;
27 typedef Eagle::rgba_t rgba;
28
29/*
30struct rgb
31{
32 unsigned char r,g,b;
33
34#if 1
35 rgb()
36 {}
37#else
38 rgb()
39 : r(0), g(0), b(0)
40 {}
41#endif
42
43 rgb(unsigned char R, unsigned char G, unsigned char B)
44 : r(R), g(G), b(B)
45 {}
46
47 rgb(int R, int G, int B)
48 : r(clamp_int_to_byte(R)), g(clamp_int_to_byte(G)), b(clamp_int_to_byte(B) )
49 {}
50};
51*/
52
53
54 /*
55struct rgba
56{
57 unsigned char r,g,b, a;
58
60 rgba()
61 {}
62
63 rgba(unsigned char R, unsigned char G, unsigned char B, unsigned char A)
64 : r(R), g(G), b(B), a(A)
65 {}
66
67static unsigned char clamp(int i)
68 {
69 if (i<0) return 0;
70 if (i>255) return 255;
71 return i;
72 }
73
74 rgba(int R, int G, int B, int A)
75 : r(clamp_int_to_byte(R)), g(clamp_int_to_byte(G)), b(clamp_int_to_byte(B)), a(clamp_int_to_byte(A) )
76 {}
77
78};
79 */
80
81struct bgr
82{
83 unsigned b,g,r;
84};
85
86
87 typedef Eagle::rgb16_t rgb16;
88 typedef Eagle::rgb_float_t rgb_real;
90
91
92/*
93struct rgb16
94{
95 unsigned short r,g,b;
96};
97
98struct rgb_real
99{
100 float r,g,b;
101
102 rgb_real(double R, double G, double B)
103 : r(R), g(G), b(B)
104 {}
105
106static inline unsigned char clamp(double d)
107 {
108 if (d<0) return 0;
109 if (d>255) return 255;
110 return (unsigned char)d;
111 }
112
113 operator rgb() const
114 {
115 return rgb( clamp(r), clamp(g), clamp(b) );
116 }
117};
118
119struct rgba_real
120{
121 float r,g,b,a;
122};
123
124*/
125
126
127#if 0
128inline rgb_real mult8bit(const rgb&c, double d)
129{
130 return rgb_real(c[0]*d, c[1]*d, c[2]*d);
131}
132#endif
133
134
135inline rgb_real mult(const rgb_real&l, const rgb_real&r)
136{
137 return rgb_real( { l[0]*r[0], l[1]*r[1], l[2]*r[2] } );
138}
139
140
141/*
142inline rgb_real operator+(const rgb_real&l, const rgb_real&r)
143{
144 return rgb_real(l[0]+r[0], l.g+r.g, l.b+r.b);
145}
146
147inline rgb_real operator-(const rgb_real&l, const rgb_real&r)
148{
149 return rgb_real(l.r-r.r, l.g-r.g, l.b-r.b);
150}
151*/
152
153} // namespace Fiber
154
155namespace Eagle
156{
157
158
159} // Eagle
160
161
162#endif // __FIBER_FIELD_COLOR_HPP
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
Definition Color.hpp:82