Get rid of Color implementation in old basics.cc
This commit is contained in:
parent
b001ad2cf2
commit
42bef33775
1 changed files with 0 additions and 214 deletions
214
src/basics.cc
214
src/basics.cc
|
@ -534,217 +534,3 @@ operator<<(std::ostream &os, const Ray &r)
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Colors
|
#pragma mark - Colors
|
||||||
|
|
||||||
const Color Color::Black = Color();
|
|
||||||
const Color Color::White = Color(1.0, 1.0, 1.0, 1.0);
|
|
||||||
const Color Color::Red = Color(1.0, 0.0, 0.0, 1.0);
|
|
||||||
const Color Color::Green = Color(0.0, 1.0, 0.0, 1.0);
|
|
||||||
const Color Color::Blue = Color(0.0, 0.0, 1.0, 1.0);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Color::Color --
|
|
||||||
*
|
|
||||||
* Default constructor. Create a new Color with zeros for all components (black).
|
|
||||||
*/
|
|
||||||
Color::Color()
|
|
||||||
: Color(0.0, 0.0, 0.0, 0.0)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Color::Color --
|
|
||||||
*
|
|
||||||
* Constructor. Create a new Color with the given RGB components. Alpha is 1.0.
|
|
||||||
*/
|
|
||||||
Color::Color(const float &r, const float &g, const float &b)
|
|
||||||
: Color(r, g, b, 1.0)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Color::Color --
|
|
||||||
*
|
|
||||||
* Constructor. Create a new Color with the given components.
|
|
||||||
*/
|
|
||||||
Color::Color(const float &r, const float &g, const float &b, const float &a)
|
|
||||||
: red(r), green(g), blue(b), alpha(a)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Color::operator*= --
|
|
||||||
* Color::operator/= --
|
|
||||||
* Color::operator+= --
|
|
||||||
* Color::operator-= --
|
|
||||||
*
|
|
||||||
* Perform the corresponding arithmetic operation on this color and the given scalar. These methods are destructive and
|
|
||||||
* a reference to this color is returned.
|
|
||||||
*/
|
|
||||||
Color &
|
|
||||||
Color::operator*=(const float &rhs)
|
|
||||||
{
|
|
||||||
red *= rhs;
|
|
||||||
green *= rhs;
|
|
||||||
blue *= rhs;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color &
|
|
||||||
Color::operator/=(const float &rhs)
|
|
||||||
{
|
|
||||||
return *this *= (1.0 / rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
Color &
|
|
||||||
Color::operator+=(const float &rhs)
|
|
||||||
{
|
|
||||||
red += rhs;
|
|
||||||
green += rhs;
|
|
||||||
blue += rhs;
|
|
||||||
alpha += rhs;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color &
|
|
||||||
Color::operator-=(const float &rhs)
|
|
||||||
{
|
|
||||||
return *this += -rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Color::operator* --
|
|
||||||
* Color::operator/ --
|
|
||||||
* Color::operator+ --
|
|
||||||
* Color::operator- --
|
|
||||||
*
|
|
||||||
* Perform the corresponding operation on a copy of this color and the given scalar. Return a new vector.
|
|
||||||
*/
|
|
||||||
Color
|
|
||||||
Color::operator*(const float &rhs)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return Color(*this) *= rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color
|
|
||||||
Color::operator/(const float &rhs)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return Color(*this) /= rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color
|
|
||||||
Color::operator+(const float &rhs)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return Color(*this) += rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color
|
|
||||||
Color::operator-(const float &rhs)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return Color(*this) -= rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Color::operator= --
|
|
||||||
*
|
|
||||||
* Copy the given color's values into this color. Return a reference to this color.
|
|
||||||
*/
|
|
||||||
Color &
|
|
||||||
Color::operator=(const Color &rhs)
|
|
||||||
{
|
|
||||||
red = rhs.red;
|
|
||||||
green = rhs.green;
|
|
||||||
blue = rhs.blue;
|
|
||||||
alpha = rhs.alpha;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Color &
|
|
||||||
Color::operator*=(const Color &rhs)
|
|
||||||
{
|
|
||||||
red *= rhs.red;
|
|
||||||
green *= rhs.green;
|
|
||||||
blue *= rhs.blue;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color &
|
|
||||||
Color::operator/=(const Color &rhs)
|
|
||||||
{
|
|
||||||
red *= (1.0 / rhs.red);
|
|
||||||
green *= (1.0 / rhs.green);
|
|
||||||
blue *= (1.0 / rhs.blue);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color &
|
|
||||||
Color::operator+=(const Color &rhs)
|
|
||||||
{
|
|
||||||
red += rhs.red;
|
|
||||||
green += rhs.green;
|
|
||||||
blue += rhs.blue;
|
|
||||||
alpha += rhs.alpha;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color &
|
|
||||||
Color::operator-=(const Color &rhs)
|
|
||||||
{
|
|
||||||
red -= rhs.red;
|
|
||||||
green -= rhs.green;
|
|
||||||
blue -= rhs.blue;
|
|
||||||
alpha -= rhs.alpha;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Color
|
|
||||||
Color::operator*(const Color &rhs)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return Color(*this) *= rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color
|
|
||||||
Color::operator/(const Color &rhs)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return Color(*this) /= rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color
|
|
||||||
Color::operator+(const Color &rhs)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return Color(*this) += rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color
|
|
||||||
Color::operator-(const Color &rhs)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return Color(*this) -= rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const Color
|
|
||||||
operator*(const float &lhs, const Color &rhs)
|
|
||||||
{
|
|
||||||
return rhs * lhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::ostream &
|
|
||||||
operator<<(std::ostream &os, const Color &c)
|
|
||||||
{
|
|
||||||
// Stream colors like this: <r, g, b, a>
|
|
||||||
os << "<" << c.red << ", " << c.green << ", " << c.blue << ", " << c.alpha << ">";
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue