Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SbColor.h
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Alain Dumesny (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2018 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifndef _SB_COLOR_H_
51#define _SB_COLOR_H_
52
53#include <Inventor/SbLinear.h>
54
55
57//
58// Class: SbColor
59//
60// 3D vector used to represent an RGB color. Each component of the vector is
61// a floating-point number between 0.0 and 1.0 .
62//
64
65class SbColor;
66
82class SbColor : public SbVec3f {
83 public:
88
92 SbColor(const SbVec3f vec3f)
93 { setValue(vec3f.getValue()); }
94
98 SbColor(const float rgb[3])
99 { setValue(rgb); }
100
104 SbColor(float r, float g, float b)
105 { setValue(r, g, b); }
106
107 //
108 // HSV routines. Those are 3 floats containing the Hue, Saturation and
109 // Value (same as brightness) of the color.
110 //
111
116 SbColor & setHSVValue(float h, float s, float v);
117
121 SbColor & setHSVValue(const float hsv[3])
122 { return setHSVValue(hsv[0], hsv[1], hsv[2]); }
123
127 void getHSVValue(float &h, float &s, float &v) const;
128
132 void getHSVValue(float hsv[3]) const
133 { getHSVValue(hsv[0], hsv[1], hsv[2]); }
134
135 //
136 // RGBA Packed integer color routines. The color format expressed in
137 // hexadecimal is 0xrrggbbaa, where
138 // aa is the alpha value
139 // bb is the blue value
140 // gg is the green value
141 // rr is the red value
142 // RGBA component values range from 0 to 0xFF (255).
143 //
144
145
149 void setRGBValue(unsigned char r, unsigned char g, unsigned char b)
150 { setValue(r / 255.f, g / 255.f, b / 255.f); }
151
168 SbColor &setPackedValue(uint32_t orderedRGBA, float& transparency);
169
176 uint32_t getPackedValue(float transparency = 0.0) const;
177
189 uint32_t getPackedValueEndiannessOrder(float transparency = 0.0) const;
190
191#if 1 SoDEPRECATED
194 uint32_t getPackedValueInternal(float transparency = 0.0) const {
195 return getPackedValueEndiannessOrder(transparency);
196 };
197#endif
199};
200
201#endif /* _SB_COLOR_H_ */
202
203
Color vector class.
Definition SbColor.h:82
uint32_t getPackedValueEndiannessOrder(float transparency=0.0) const
Returns an RGBA packed color value, derived from the color vector and the passed transparency value.
SbColor & setHSVValue(const float hsv[3])
Sets value of color vector from array of 3 HSV components.
Definition SbColor.h:121
void getHSVValue(float &h, float &s, float &v) const
Returns 3 individual HSV components.
void getHSVValue(float hsv[3]) const
Returns an array of 3 HSV components.
Definition SbColor.h:132
SbColor & setPackedValue(uint32_t orderedRGBA, float &transparency)
Sets value of color vector from an RGBA packed color value.
uint32_t getPackedValue(float transparency=0.0) const
Returns an RGBA packed color value, derived from the color vector and the passed transparency value.
SbColor()
Default constructor.
void setRGBValue(unsigned char r, unsigned char g, unsigned char b)
Set RGB values as unsigned char.
Definition SbColor.h:149
SbColor(float r, float g, float b)
Constructor that takes 3 floats.
Definition SbColor.h:104
SbColor & setHSVValue(float h, float s, float v)
Sets value of color vector from 3 HSV (Hue, Saturation, and Value) components.
SbColor(const SbVec3f vec3f)
Constructor that takes a vector value.
Definition SbColor.h:92
SbColor(const float rgb[3])
Constructor that takes an array of 3 floats.
Definition SbColor.h:98
SoDEPRECATED uint32_t getPackedValueInternal(float transparency=0.0) const
Definition SbColor.h:194
3D vector class.
Definition SbVec.h:932
SbVec3f & setValue(const float v[3])
Sets the vector components.
Definition SbVec.h:1010
const float * getValue() const
Returns vector components.
Definition SbVec.h:977