00001 #ifndef MERCURYCOLOR_H 00002 #define MERCURYCOLOR_H 00003 00004 #include "MercuryMath.h" 00005 00007 class MercuryColor 00008 { 00009 float m_rgba[4]; 00010 public: 00011 MercuryColor(); 00012 MercuryColor( float ir, float ig, float ib, float ia = 1 ); 00013 inline MercuryColor( const MercuryColor& c ) { c.GetValues(m_rgba); } 00014 00015 operator float* () { return m_rgba; } 00016 operator const float* () const { return m_rgba; } 00017 00018 inline void GetValues(float RGBA[4]) const { Copy4f( RGBA, m_rgba ); } 00019 inline void SetR(float r) { m_rgba[0] = r; } 00020 inline void SetG(float g) { m_rgba[1] = g; } 00021 inline void SetB(float b) { m_rgba[2] = b; } 00022 inline void SetA(float a) { m_rgba[3] = a; } 00023 inline float GetR() const { return m_rgba[0]; } 00024 inline float GetG() const { return m_rgba[1]; } 00025 inline float GetB() const { return m_rgba[2]; } 00026 inline float GetA() const { return m_rgba[3]; } 00027 00028 void FromString(const MString& str); 00029 00030 const MercuryColor operator-(const MercuryColor& c); 00031 const MercuryColor& operator-=(const MercuryColor& c); 00032 const MercuryColor operator+(const MercuryColor& c); 00033 const MercuryColor& operator+=(const MercuryColor& c); 00034 const MercuryColor operator*(const float f); 00035 const MercuryColor operator*(const MercuryColor& c); 00036 const MercuryColor& operator*=(const MercuryColor& c); 00037 inline const MercuryColor& operator=(const MercuryColor& c) { Copy4f( m_rgba, c.m_rgba ); return *this; } 00038 } M_ALIGN(32); 00039 00040 #endif 00041 00042 /* 00043 * Copyright (c) 2005-2006, Joshua Allen 00044 * All rights reserved. 00045 * 00046 * Redistribution and use in source and binary forms, with or 00047 * without modification, are permitted provided that the following 00048 * conditions are met: 00049 * - Redistributions of source code must retain the above 00050 * copyright notice, this list of conditions and the following disclaimer. 00051 * - Redistributions in binary form must reproduce the above copyright 00052 * notice, this list of conditions and the following disclaimer in 00053 * the documentation and/or other materials provided with the distribution. 00054 * - Neither the name of the Mercury Engine nor the names of its 00055 * contributors may be used to endorse or promote products derived from 00056 * this software without specific prior written permission. 00057 * 00058 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00059 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00060 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00061 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 00062 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00063 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00064 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00065 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00066 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00067 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00068 */