Panda3D
 All Classes Functions Variables Enumerations
fltPackedColor.I
00001 // Filename: fltPackedColor.I
00002 // Created by:  drose (25Aug00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 INLINE ostream &
00016 operator << (ostream &out, const FltPackedColor &color) {
00017   color.output(out);
00018   return out;
00019 }
00020 
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //     Function: FltPackedColor::Constructor
00024 //       Access: Public
00025 //  Description:
00026 ////////////////////////////////////////////////////////////////////
00027 INLINE FltPackedColor::
00028 FltPackedColor() {
00029   _a = 0;
00030   _b = 0;
00031   _g = 0;
00032   _r = 0;
00033 }
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //     Function: FltPackedColor::get_color
00037 //       Access: Public
00038 //  Description: Returns the four-component color as a LColor, where
00039 //               each component is in the range [0, 1].
00040 ////////////////////////////////////////////////////////////////////
00041 INLINE LColor FltPackedColor::
00042 get_color() const {
00043   return LColor(_r / 255.0, _g / 255.0, _b / 255.0, _a / 255.0);
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: FltPackedColor::get_rgb
00048 //       Access: Public
00049 //  Description: Returns the three-component color as an LRGBColor
00050 //               (ignoring the alpha component), where each component
00051 //               is in the range [0, 1].
00052 ////////////////////////////////////////////////////////////////////
00053 INLINE LRGBColor FltPackedColor::
00054 get_rgb() const {
00055   return LRGBColor(_r / 255.0, _g / 255.0, _b / 255.0);
00056 }
00057 
00058 ////////////////////////////////////////////////////////////////////
00059 //     Function: FltPackedColor::set_color
00060 //       Access: Public
00061 //  Description: Sets the color according to the indicated
00062 //               four-component LColor value (including alpha).
00063 ////////////////////////////////////////////////////////////////////
00064 INLINE void FltPackedColor::
00065 set_color(const LColor &color) {
00066   _r = (int)floor(color[0] * 255.0);
00067   _g = (int)floor(color[1] * 255.0);
00068   _b = (int)floor(color[2] * 255.0);
00069   _a = (int)floor(color[3] * 255.0);
00070 }
00071 
00072 ////////////////////////////////////////////////////////////////////
00073 //     Function: FltPackedColor::set_rgb
00074 //       Access: Public
00075 //  Description: Sets the color according to the indicated
00076 //               three-component LRGBColor value, and set the alpha to
00077 //               1.0.
00078 ////////////////////////////////////////////////////////////////////
00079 INLINE void FltPackedColor::
00080 set_rgb(const LRGBColor &color) {
00081   _r = (int)floor(color[0] * 255.0);
00082   _g = (int)floor(color[1] * 255.0);
00083   _b = (int)floor(color[2] * 255.0);
00084   _a = 255;
00085 }
 All Classes Functions Variables Enumerations