// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//

BALL_INLINE
ColorUnit::operator String () const
{
  char temp[4];
  sprintf(&temp[0], "%x", (unsigned char)(value_ * 255.0));
  return String(&temp[0]);
}

BALL_INLINE
ColorUnit::operator char () const
{
  return (char)(value_ * (float)255.0);
}

BALL_INLINE
ColorUnit::operator unsigned char () const
{
  return (unsigned char)(value_ * (float)255.0);
}

BALL_INLINE
ColorUnit::operator short () const
{
  return (short)(value_ * (float)255.0);
}

BALL_INLINE
ColorUnit::operator unsigned short () const
{
  return (unsigned short)(value_ * (float)255.0);
}

BALL_INLINE
ColorUnit::operator int () const
{
  return (int)(value_ * (float)255.0);
}

BALL_INLINE
ColorUnit::operator unsigned int () const
{
  return (unsigned int)(value_ * (float)255.0);
}

BALL_INLINE
ColorUnit::operator long () const
{
  return (long)(value_ * (float)255.0);
}

BALL_INLINE
ColorUnit::operator unsigned long () const
{
  return (unsigned long)(value_ * (float)255.0);
}

BALL_INLINE
ColorUnit::operator float () const
{
  return value_;
}

BALL_INLINE
ColorUnit::operator double () const
{
  return (double)value_;
}

BALL_INLINE
bool ColorUnit::operator == (const ColorUnit& color_unit) const
{
  return Maths::isEqual(value_, color_unit.value_);
}

BALL_INLINE
bool ColorUnit::operator != (const ColorUnit& color_unit) const
{
  return Maths::isNotEqual(value_, color_unit.value_);
}
    
BALL_INLINE
bool ColorUnit::operator < (const ColorUnit& color_unit) const
{
  return Maths::isLess(value_, color_unit.value_);
}
    
BALL_INLINE
bool ColorUnit::operator <= (const ColorUnit& color_unit) const
{
  return Maths::isLessOrEqual(value_, color_unit.value_);
}
    
BALL_INLINE
bool ColorUnit::operator > (const ColorUnit& color_unit) const
{
  return Maths::isGreater(value_, color_unit.value_);
}
    
BALL_INLINE
bool ColorUnit::operator >= (const ColorUnit& color_unit) const
{
  return Maths::isGreaterOrEqual(value_, color_unit.value_);
}
