From 7c0f8391ade0b85a4d07c8aef19f0c0c3608cf75 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sat, 21 Nov 2015 21:49:08 +0100 Subject: [PATCH] [DEV] update Color class --- etk/Color.h | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/etk/Color.h b/etk/Color.h index 1c450b5..30b9ef3 100644 --- a/etk/Color.h +++ b/etk/Color.h @@ -283,6 +283,78 @@ namespace etk { m_element[3] = MY_TYPE(_a); } }; + /* **************************************************** + * += operator + *****************************************************/ + const etk::Color& operator+= (const etk::Color& _obj) { + if (MY_TYPE_SIZE >= 1) { + m_element[0] += _obj.m_element[0]; + } + if (MY_TYPE_SIZE >= 2) { + m_element[1] += _obj.m_element[1]; + } + if (MY_TYPE_SIZE >= 3) { + m_element[2] += _obj.m_element[2]; + } + if (MY_TYPE_SIZE >= 4) { + m_element[3] += _obj.m_element[3]; + } + return *this; + } + /* **************************************************** + * + operator + *****************************************************/ + etk::Color operator+ (const etk::Color& _obj) const { + etk::Color tmpp(*this); + tmpp += _obj; + return tmpp; + } + /* **************************************************** + * *= operator + *****************************************************/ + const etk::Color& operator*= (const etk::Color& _obj) { + if (MY_TYPE_SIZE >= 1) { + m_element[0] *= _obj.m_element[0]; + } + if (MY_TYPE_SIZE >= 2) { + m_element[1] *= _obj.m_element[1]; + } + if (MY_TYPE_SIZE >= 3) { + m_element[2] *= _obj.m_element[2]; + } + if (MY_TYPE_SIZE >= 4) { + m_element[3] *= _obj.m_element[3]; + } + return *this; + } + const etk::Color& operator*= (const MY_TYPE _val) { + if (MY_TYPE_SIZE >= 1) { + m_element[0] *= _val; + } + if (MY_TYPE_SIZE >= 2) { + m_element[1] *= _val; + } + if (MY_TYPE_SIZE >= 3) { + m_element[2] *= _val; + } + if (MY_TYPE_SIZE >= 4) { + m_element[3] *= _val; + } + return *this; + } + /* **************************************************** + * * operator + *****************************************************/ + etk::Color operator* (const etk::Color& _obj) const { + etk::Color tmpp(*this); + tmpp *= _obj; + return tmpp; + } + etk::Color operator* (const MY_TYPE _val) const { + etk::Color tmpp(*this); + tmpp *= _val; + return tmpp; + } }; etk::Color parseStringStartWithSharp(const std::string& _input); etk::Color parseStringStartWithRGBGen(const std::string& _input);