1 /*
2     Copyright (c) 2008-2009 NetAllied Systems GmbH
3 
4     This file is part of COLLADAStreamWriter.
5 
6     Licensed under the MIT Open Source License,
7     for details please see LICENSE file or the website
8     http://www.opensource.org/licenses/mit-license.php
9 */
10 
11 #ifndef __COLLADAFRAMEWORK_COLOR_H__
12 #define __COLLADAFRAMEWORK_COLOR_H__
13 
14 #include "COLLADAFWStableHeaders.h"
15 #include "COLLADAFWPrerequisites.h"
16 #include "COLLADAFWAnimatable.h"
17 
18 
19 namespace COLLADAFW
20 {
21 
22     class Color : public Animatable
23     {
24 
25     private:
26 
27         double mR;
28         double mG;
29         double mB;
30         double mA;
31         String mSid;
32 
33     public:
34 
35         Color( double r, double g, double b, double a, String sid="" )
mR(r)36             : mR( r ), mG( g ), mB( b ), mA( a ), mSid( sid ) {}
37 
38         /** Creates a color with opacity 1.*/
39         Color( double r, double g, double b, String sid="" )
mR(r)40             : mR( r ), mG( g ), mB( b ), mA( 1 ), mSid( sid ) {}
41 
42         /** Creates an invalid color*/
Color()43         Color( )
44             : mR( -1 ), mG( -1 ), mB( -1 ), mA( -1 ), mSid( "" ) {}
45 
46         /** Sets the values of color*/
47         void set( double r, double g, double b, double a, String sid="" );
48 
49         /** Return true if the color is valid, false otherwise*/
50         bool isValid() const;
51 
52         /** Returns the red component*/
getRed()53         double getRed() const {return mR; }
54 
55 		/** Sets the red component*/
setRed(double r)56 		void setRed( double r ) {mR = r; }
57 
58         /** Returns the green component*/
getGreen()59         double getGreen() const { return mG; }
60 
61 		/** Sets the green component*/
setGreen(double g)62 		void setGreen( double g ) {mG = g; }
63 
64         /** Returns the blue component*/
getBlue()65         double getBlue() const { return mB; }
66 
67 		/** Sets the red component*/
setBlue(double b)68 		void setBlue( double b ) {mB = b; }
69 
70         /** Returns the alpha component*/
getAlpha()71         double getAlpha() const { return mA; }
72 
73 		/** Sets the red component*/
setAlpha(double a)74 		void setAlpha( double a ) {mA = a; }
75 
76         /** A white color object*/
77         static const Color WHITE;
78 
79         /** A black color object*/
80         static const Color BLACK;
81 
82         /** A grey color object*/
83         static const Color GREY;
84 
85         /** Operator overloading. */
86         bool operator==(const Color& uid) const;
87         bool operator!=(const Color& uid) const;
88 
89     };
90 
91 } //namespace COLLADAFW
92 
93 
94 #endif //__COLLADAFRAMEWORK_COLOR_H__
95