From 09fb43f3d36847977ac202c10c5a11f34af03a43 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 4 Feb 2008 01:17:44 +0000 Subject: astyle --- src/math/color.cc | 50 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 18 deletions(-) (limited to 'src/math/color.cc') diff --git a/src/math/color.cc b/src/math/color.cc index e41a5aa..b0c3f65 100644 --- a/src/math/color.cc +++ b/src/math/color.cc @@ -1,36 +1,42 @@ /* math/color.cc - This file is part of the Osirion project and is distributed under - the terms of the GNU General Public License version 2 + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 */ // project headers #include "math/color.h" -namespace math { +namespace math +{ -Color::Color() { +Color::Color() +{ _r = _g = _b = 0.0f; _a = 1.0f; } -Color::Color(const float red, const float green , const float blue , const float alpha) { +Color::Color(const float red, const float green , const float blue , const float alpha) +{ _r = red; _g = green; _b = blue; _a = alpha; } -Color::Color(const float grey, const float alpha) { +Color::Color(const float grey, const float alpha) +{ _r = _g = _b = grey; _a = alpha; } -Color::Color(const Color &other) { +Color::Color(const Color &other) +{ this->operator=(other); } -const Color & Color::operator=(const Color &other) { +const Color & Color::operator=(const Color &other) +{ this->_r = other._r; this->_g = other._g; this->_b = other._b; @@ -38,45 +44,53 @@ const Color & Color::operator=(const Color &other) { return (*this); } -void Color::normalize() { +void Color::normalize() +{ float tmp = _r; if (_g > tmp) tmp = _g; - if ( _b > tmp) + if (_b > tmp) tmp = _b; if (tmp > 1) { _r /= tmp; _g /= tmp; _b /= tmp; - } + } } -float Color::red() const { +float Color::red() const +{ return _r; } -float Color::green() const { +float Color::green() const +{ return _g; } -float Color::blue() const { +float Color::blue() const +{ return _b; } -float Color::alpha() const { +float Color::alpha() const +{ return _a; } -Color Color::operator*(float scalar) const { +Color Color::operator*(float scalar) const +{ return Color(red()*scalar, green()*scalar, blue()*scalar, alpha()); } -Color operator*(float scalar, const Color& color) { +Color operator*(float scalar, const Color& color) +{ return color * scalar; } -std::ostream &operator<<(std::ostream &os, const Color &c) { +std::ostream &operator<<(std::ostream &os, const Color &c) +{ os << c.red() << " " << c.green() << " " << c.blue() << " " << c.alpha(); return os; } -- cgit v1.2.3