Add operator*= to colors

This commit is contained in:
Eryn Wells 2013-09-11 08:56:53 -07:00
parent 51c79b9b76
commit c6c11ca95a
2 changed files with 14 additions and 2 deletions

View file

@ -198,7 +198,8 @@ Ray::Ray(Vector3 o, Vector3 d)
* Compute and return the point given by parameterizing this Ray by time t. * Compute and return the point given by parameterizing this Ray by time t.
*/ */
Vector3 Vector3
Ray::parameterize(float t) Ray::parameterize(const float t)
const
{ {
return origin + t * direction; return origin + t * direction;
} }
@ -241,3 +242,13 @@ Color::operator=(const Color &c)
alpha = c.alpha; alpha = c.alpha;
return *this; return *this;
} }
Color &
Color::operator*=(const float f)
{
red *= f;
green *= f;
blue *= f;
return *this;
}

View file

@ -42,7 +42,7 @@ struct Ray
Ray(); Ray();
Ray(Vector3 o, Vector3 d); Ray(Vector3 o, Vector3 d);
Vector3 parameterize(float t); Vector3 parameterize(const float t) const;
Vector3 origin, direction; Vector3 origin, direction;
}; };
@ -54,6 +54,7 @@ struct Color
Color(float r, float g, float b, float a); Color(float r, float g, float b, float a);
Color &operator=(const Color &c); Color &operator=(const Color &c);
Color &operator*=(const float c);
static const Color Black; static const Color Black;
static const Color White; static const Color White;