arithmetic operators for Color4F (#18028)

* arithmetic operators for Color4F

* remove template functions
This commit is contained in:
kepler-5 2017-07-04 18:05:03 -07:00 коммит произвёл minggo
Родитель f2e9785132
Коммит c8fc2dc3ef
2 изменённых файлов: 82 добавлений и 0 удалений

Просмотреть файл

@ -214,6 +214,71 @@ bool Color4F::operator!=(const Color4B& right) const
return !(*this == right);
}
Color4F& operator+=(Color4F& lhs, const Color4F& rhs) {
lhs.r += rhs.r;
lhs.g += rhs.g;
lhs.b += rhs.b;
lhs.a += rhs.a;
return lhs;
}
Color4F operator+(Color4F lhs, const Color4F& rhs) {
return lhs += rhs;
}
Color4F& operator-=(Color4F& lhs, const Color4F& rhs) {
lhs.r -= rhs.r;
lhs.g -= rhs.g;
lhs.b -= rhs.b;
lhs.a -= rhs.a;
return lhs;
}
Color4F operator-(Color4F lhs, const Color4F& rhs) {
return lhs -= rhs;
}
Color4F& operator*=(Color4F& lhs, const Color4F& rhs) {
lhs.r *= rhs.r;
lhs.g *= rhs.g;
lhs.b *= rhs.b;
lhs.a *= rhs.a;
return lhs;
}
Color4F& operator*=(Color4F& lhs, float rhs) {
lhs.r *= rhs;
lhs.g *= rhs;
lhs.b *= rhs;
lhs.a *= rhs;
return lhs;
}
Color4F operator*(Color4F lhs, const Color4F& rhs) {
return lhs *= rhs;
}
Color4F operator*(Color4F lhs, float rhs) {
return lhs *= rhs;
}
Color4F& operator/=(Color4F& lhs, const Color4F& rhs) {
lhs.r /= rhs.r;
lhs.g /= rhs.g;
lhs.b /= rhs.b;
lhs.a /= rhs.a;
return lhs;
}
Color4F& operator/=(Color4F& lhs, float rhs) {
lhs.r /= rhs;
lhs.g /= rhs;
lhs.b /= rhs;
lhs.a /= rhs;
return lhs;
}
Color4F operator/(Color4F lhs, const Color4F& rhs) {
return lhs /= rhs;
}
Color4F operator/(Color4F lhs, float rhs) {
return lhs /= rhs;
}
/**
* Color constants
*/

Просмотреть файл

@ -165,6 +165,23 @@ struct CC_DLL Color4F
static const Color4F GRAY;
};
Color4F& operator+=(Color4F& lhs, const Color4F& rhs);
Color4F operator+(Color4F lhs, const Color4F& rhs);
Color4F& operator-=(Color4F& lhs, const Color4F& rhs);
Color4F operator-(Color4F lhs, const Color4F& rhs);
Color4F& operator*=(Color4F& lhs, const Color4F& rhs);
Color4F operator*(Color4F lhs, const Color4F& rhs);
Color4F& operator*=(Color4F& lhs, float rhs);
Color4F operator*(Color4F lhs, float rhs);
Color4F& operator/=(Color4F& lhs, const Color4F& rhs);
Color4F operator/(Color4F lhs, const Color4F& rhs);
Color4F& operator/=(Color4F& lhs, float rhs);
Color4F operator/(Color4F lhs, float rhs);
/** A vertex composed of 2 floats: x, y
@since v3.0
*/