Advertisement
keybode

source engine Color class

Dec 19th, 2014
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. class Color
  2. {
  3. public:
  4.     Color ()
  5.         :   R ( 0 ),
  6.             G ( 0 ),
  7.             B ( 0 ),
  8.             A ( 0 )
  9.     {
  10.        
  11.     }
  12.  
  13.     Color ( int r, int g, int b, int a )
  14.         :   R ( r ),
  15.             G ( g ),
  16.             B ( b ),
  17.             A ( a )
  18.     {
  19.        
  20.     }
  21.  
  22.     Color ( int r, int g, int b )
  23.         :   R ( r ),
  24.             G ( g ),
  25.             B ( b ),
  26.             A ( 255 )
  27.     {
  28.        
  29.     }
  30.  
  31.     static Color White ( void ) { return Color ( 255, 255, 255, 255 ); }
  32.     static Color Black ( void ) { return Color ( 0, 0, 0, 255 ); }
  33.     static Color Red ( void ) { return Color ( 255, 0, 0, 255 ); }
  34.     static Color Green ( void ) { return Color ( 0, 255, 0, 255 ); }
  35.     static Color Blue ( void ) { return Color ( 0, 0, 255, 255 ); }
  36.     static Color Cyan ( void ) { return Color ( 0, 127, 255, 255 ); }
  37.     static Color Yellow ( void ) { return Color ( 255, 255, 0, 255 ); }
  38.  
  39.     int r ( void ) { return R; }
  40.     int g ( void ) { return G; }
  41.     int b ( void ) { return B; }
  42.     int a ( void ) { return A; }
  43.  
  44.     Color& operator = ( Color& c )
  45.     {
  46.         R = c.r ();
  47.         G = c.g ();
  48.         B = c.b ();
  49.         A = c.a ();
  50.         return *this;
  51.     }
  52.  
  53. private:
  54.     int R, G, B, A;
  55. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement