зеркало из https://github.com/microsoft/cocos2d-x.git
arithmetic operators for Color4F (#18028)
* arithmetic operators for Color4F * remove template functions
This commit is contained in:
Родитель
f2e9785132
Коммит
c8fc2dc3ef
|
@ -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
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче