Panda3D
fltPackedColor.I
1 // Filename: fltPackedColor.I
2 // Created by: drose (25Aug00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 INLINE ostream &
16 operator << (ostream &out, const FltPackedColor &color) {
17  color.output(out);
18  return out;
19 }
20 
21 
22 ////////////////////////////////////////////////////////////////////
23 // Function: FltPackedColor::Constructor
24 // Access: Public
25 // Description:
26 ////////////////////////////////////////////////////////////////////
27 INLINE FltPackedColor::
28 FltPackedColor() {
29  _a = 0;
30  _b = 0;
31  _g = 0;
32  _r = 0;
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function: FltPackedColor::get_color
37 // Access: Public
38 // Description: Returns the four-component color as a LColor, where
39 // each component is in the range [0, 1].
40 ////////////////////////////////////////////////////////////////////
42 get_color() const {
43  return LColor(_r / 255.0, _g / 255.0, _b / 255.0, _a / 255.0);
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: FltPackedColor::get_rgb
48 // Access: Public
49 // Description: Returns the three-component color as an LRGBColor
50 // (ignoring the alpha component), where each component
51 // is in the range [0, 1].
52 ////////////////////////////////////////////////////////////////////
54 get_rgb() const {
55  return LRGBColor(_r / 255.0, _g / 255.0, _b / 255.0);
56 }
57 
58 ////////////////////////////////////////////////////////////////////
59 // Function: FltPackedColor::set_color
60 // Access: Public
61 // Description: Sets the color according to the indicated
62 // four-component LColor value (including alpha).
63 ////////////////////////////////////////////////////////////////////
64 INLINE void FltPackedColor::
65 set_color(const LColor &color) {
66  _r = (int)floor(color[0] * 255.0);
67  _g = (int)floor(color[1] * 255.0);
68  _b = (int)floor(color[2] * 255.0);
69  _a = (int)floor(color[3] * 255.0);
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: FltPackedColor::set_rgb
74 // Access: Public
75 // Description: Sets the color according to the indicated
76 // three-component LRGBColor value, and set the alpha to
77 // 1.0.
78 ////////////////////////////////////////////////////////////////////
79 INLINE void FltPackedColor::
80 set_rgb(const LRGBColor &color) {
81  _r = (int)floor(color[0] * 255.0);
82  _g = (int)floor(color[1] * 255.0);
83  _b = (int)floor(color[2] * 255.0);
84  _a = 255;
85 }
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
void set_rgb(const LRGBColor &rgb)
Sets the color according to the indicated three-component LRGBColor value, and set the alpha to 1...
LRGBColor get_rgb() const
Returns the three-component color as an LRGBColor (ignoring the alpha component), where each componen...
void set_color(const LColor &color)
Sets the color according to the indicated four-component LColor value (including alpha).
A packed color record, A, B, G, R.
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
LColor get_color() const
Returns the four-component color as a LColor, where each component is in the range [0...