mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 21:41:26 +12:00
geometry: Allow basic color arithmetic
This commit is contained in:
parent
ad845861be
commit
071e73a68e
1 changed files with 40 additions and 1 deletions
|
@ -856,7 +856,7 @@ struct color4_base
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr color4_base(T x, T y = {}, T z = {}, T w = {})
|
constexpr color4_base(T x, T y, T z, T w)
|
||||||
: x(x)
|
: x(x)
|
||||||
, y(y)
|
, y(y)
|
||||||
, z(z)
|
, z(z)
|
||||||
|
@ -864,6 +864,14 @@ struct color4_base
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr color4_base(T value)
|
||||||
|
: x(value)
|
||||||
|
, y(value)
|
||||||
|
, z(value)
|
||||||
|
, w(value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
constexpr bool operator == (const color4_base& rhs) const
|
constexpr bool operator == (const color4_base& rhs) const
|
||||||
{
|
{
|
||||||
return r == rhs.r && g == rhs.g && b == rhs.b && a == rhs.a;
|
return r == rhs.r && g == rhs.g && b == rhs.b && a == rhs.a;
|
||||||
|
@ -874,6 +882,37 @@ struct color4_base
|
||||||
return !(*this == rhs);
|
return !(*this == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void operator *= (const color4_base<T>& rhs)
|
||||||
|
{
|
||||||
|
r *= rhs.r;
|
||||||
|
g *= rhs.g;
|
||||||
|
b *= rhs.b;
|
||||||
|
a *= rhs.a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator *= (const T& rhs)
|
||||||
|
{
|
||||||
|
r *= rhs;
|
||||||
|
g *= rhs;
|
||||||
|
b *= rhs;
|
||||||
|
a *= rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr color4_base<T> operator * (const color4_base<T>& rhs) const
|
||||||
|
{
|
||||||
|
return { r * rhs.r, g * rhs.g, b * rhs.b, a * rhs.a };
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr color4_base<T> operator * (const T& rhs) const
|
||||||
|
{
|
||||||
|
return { r * rhs, g * rhs, b * rhs, a * rhs };
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr color4_base<T> operator + (const color4_base<T>& rhs) const
|
||||||
|
{
|
||||||
|
return { r + rhs.r, g + rhs.g, b + rhs.b, a + rhs.a };
|
||||||
|
}
|
||||||
|
|
||||||
template<typename NT>
|
template<typename NT>
|
||||||
constexpr operator color4_base<NT>() const
|
constexpr operator color4_base<NT>() const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue