From c6c11ca95a7fc70d7de0bffe3e860e9f09976487 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Wed, 11 Sep 2013 08:56:53 -0700 Subject: [PATCH] Add operator*= to colors --- src/basics.cc | 13 ++++++++++++- src/basics.h | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/basics.cc b/src/basics.cc index f7ad01e..31884a5 100644 --- a/src/basics.cc +++ b/src/basics.cc @@ -198,7 +198,8 @@ Ray::Ray(Vector3 o, Vector3 d) * Compute and return the point given by parameterizing this Ray by time t. */ Vector3 -Ray::parameterize(float t) +Ray::parameterize(const float t) + const { return origin + t * direction; } @@ -241,3 +242,13 @@ Color::operator=(const Color &c) alpha = c.alpha; return *this; } + + +Color & +Color::operator*=(const float f) +{ + red *= f; + green *= f; + blue *= f; + return *this; +} diff --git a/src/basics.h b/src/basics.h index aca6795..a69fe6b 100644 --- a/src/basics.h +++ b/src/basics.h @@ -42,7 +42,7 @@ struct Ray Ray(); Ray(Vector3 o, Vector3 d); - Vector3 parameterize(float t); + Vector3 parameterize(const float t) const; Vector3 origin, direction; }; @@ -54,6 +54,7 @@ struct Color Color(float r, float g, float b, float a); Color &operator=(const Color &c); + Color &operator*=(const float c); static const Color Black; static const Color White;