Avogadro
1.1.0
|
00001 /********************************************************************** 00002 Color3f - Simple color class that uses three floats to represent RGB 00003 00004 Copyright (C) 2009 Marcus D. Hanwell 00005 00006 This file is part of the Avogadro molecular editor project. 00007 For more information, see <http://avogadro.openmolecules.net/> 00008 00009 Avogadro is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU Lesser General Public License as published by 00011 the Free Software Foundation; either version 2.1 of the License, or 00012 (at your option) any later version. 00013 00014 Avogadro is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00022 02110-1301, USA. 00023 **********************************************************************/ 00024 00025 #ifndef COLOR3F_H 00026 #define COLOR3F_H 00027 00028 namespace Avogadro { 00029 00044 class Color3f 00045 { 00046 public: 00054 Color3f(float red = 0.0, float green = 0.0, float blue = 0.0); 00055 00062 Color3f(int red, int green, int blue); 00063 00070 void set(float red, float green, float blue); 00071 00075 float red() const { return m_data[0]; } 00076 00080 float green() const { return m_data[1]; } 00081 00085 float blue() const { return m_data[2]; } 00086 00090 float * data(); 00091 00097 const float * data() const; 00098 00099 protected: 00100 float m_data[3]; 00101 }; 00102 00103 inline Color3f::Color3f(float red, float green, float blue) 00104 { 00105 m_data[0] = red; 00106 m_data[1] = green; 00107 m_data[2] = blue; 00108 } 00109 00110 inline Color3f::Color3f(int red, int green, int blue) 00111 { 00112 m_data[0] = red / 255.0f; 00113 m_data[1] = green / 255.0f; 00114 m_data[2] = blue / 255.0f; 00115 } 00116 00117 inline void Color3f::set(float red, float green, float blue) 00118 { 00119 m_data[0] = red; 00120 m_data[1] = green; 00121 m_data[2] = blue; 00122 } 00123 00124 inline float * Color3f::data() 00125 { 00126 return &(m_data[0]); 00127 } 00128 00129 inline const float * Color3f::data() const 00130 { 00131 return &(m_data[0]); 00132 } 00133 00134 } // End namespace Avogadro 00135 00136 #endif // COLOR3F_H