Panda3D
Loading...
Searching...
No Matches
fltPackedColor.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file fltPackedColor.I
10 * @author drose
11 * @date 2000-08-25
12 */
13
14INLINE std::ostream &
15operator << (std::ostream &out, const FltPackedColor &color) {
16 color.output(out);
17 return out;
18}
19
20
21/**
22 *
23 */
24INLINE FltPackedColor::
25FltPackedColor() {
26 _a = 0;
27 _b = 0;
28 _g = 0;
29 _r = 0;
30}
31
32/**
33 * Returns the four-component color as a LColor, where each component is in
34 * the range [0, 1].
35 */
36INLINE LColor FltPackedColor::
37get_color() const {
38 return LColor(_r / 255.0, _g / 255.0, _b / 255.0, _a / 255.0);
39}
40
41/**
42 * Returns the three-component color as an LRGBColor (ignoring the alpha
43 * component), where each component is in the range [0, 1].
44 */
45INLINE LRGBColor FltPackedColor::
46get_rgb() const {
47 return LRGBColor(_r / 255.0, _g / 255.0, _b / 255.0);
48}
49
50/**
51 * Sets the color according to the indicated four-component LColor value
52 * (including alpha).
53 */
55set_color(const LColor &color) {
56 _r = (int)floor(color[0] * 255.0);
57 _g = (int)floor(color[1] * 255.0);
58 _b = (int)floor(color[2] * 255.0);
59 _a = (int)floor(color[3] * 255.0);
60}
61
62/**
63 * Sets the color according to the indicated three-component LRGBColor value,
64 * and set the alpha to 1.0.
65 */
67set_rgb(const LRGBColor &color) {
68 _r = (int)floor(color[0] * 255.0);
69 _g = (int)floor(color[1] * 255.0);
70 _b = (int)floor(color[2] * 255.0);
71 _a = 255;
72}
A packed color record, A, B, G, R.
void set_color(const LColor &color)
Sets the color according to the indicated four-component LColor value (including alpha).
LColor get_color() const
Returns the four-component color as a LColor, where each component is in the range [0,...
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...