////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------- //
//                                                                            //
//                       (C) 2010-2016 Robot Developers                       //
//                       See LICENSE for licensing info                       //
//                                                                            //
// -------------------------------------------------------------------------- //
////////////////////////////////////////////////////////////////////////////////

//----------------------------------------------------------------------------//
// Prefaces                                                                   //
//----------------------------------------------------------------------------//

#include "Color.h"
ROBOT_NS_BEGIN



//----------------------------------------------------------------------------//
// Constructors                                                         Color //
//----------------------------------------------------------------------------//

////////////////////////////////////////////////////////////////////////////////

Color::Color (uint32 argb)
{
	A = (uint8) ((argb & 0xFF000000) >> 24);
	R = (uint8) ((argb & 0x00FF0000) >> 16);
	G = (uint8) ((argb & 0x0000FF00) >>  8);
	B = (uint8) ((argb & 0x000000FF) >>  0);
}

////////////////////////////////////////////////////////////////////////////////

Color::Color (uint8 r, uint8 g,
			  uint8 b, uint8 a)
{
	A = a;
	R = r;
	G = g;
	B = b;
}



//----------------------------------------------------------------------------//
// Functions                                                            Color //
//----------------------------------------------------------------------------//

////////////////////////////////////////////////////////////////////////////////

uint32 Color::GetARGB (void) const
{
	return (A << 24) | (R << 16) | (G << 8) | B;
}

////////////////////////////////////////////////////////////////////////////////

void Color::SetARGB (uint32 argb)
{
	A = (uint8) ((argb & 0xFF000000) >> 24);
	R = (uint8) ((argb & 0x00FF0000) >> 16);
	G = (uint8) ((argb & 0x0000FF00) >>  8);
	B = (uint8) ((argb & 0x000000FF) >>  0);
}



//----------------------------------------------------------------------------//
// Operators                                                            Color //
//----------------------------------------------------------------------------//

////////////////////////////////////////////////////////////////////////////////

bool Color::operator == (const Color& color) const
{
	return A == color.A && R == color.R &&
		   G == color.G && B == color.B;
}

////////////////////////////////////////////////////////////////////////////////

bool Color::operator != (const Color& color) const
{
	return A != color.A || R != color.R ||
		   G != color.G || B != color.B;
}

ROBOT_NS_END
