12 constexpr Color() noexcept :
r{ 0 },
g{ 0 },
b{ 0 },
a{ 255 } {}
14 constexpr Color(
int r,
int g,
int b,
int a ) noexcept :
r{uint8_t(
r)},
g{uint8_t(
g)},
b{uint8_t(
b)},
a{uint8_t(
a)} {}
15 constexpr Color(
int r,
int g,
int b ) noexcept :
r{uint8_t(
r)},
g{uint8_t(
g)},
b{uint8_t(
b)},
a{255} {}
16 constexpr Color(
float r,
float g,
float b,
float a ) noexcept :
17 r{
r > 1 ? uint8_t( 255 ) : (
r < 0 ? uint8_t( 0 ) : uint8_t(
r * 255 ) )},
18 g{
g > 1 ? uint8_t( 255 ) : (
g < 0 ? uint8_t( 0 ) : uint8_t(
g * 255 ) )},
19 b{
b > 1 ? uint8_t( 255 ) : (
b < 0 ? uint8_t( 0 ) : uint8_t(
b * 255 ) )},
20 a{
a > 1 ? uint8_t( 255 ) : (
a < 0 ? uint8_t( 0 ) : uint8_t(
a * 255 ) )} {}
23 constexpr unsigned int getUInt32() const noexcept {
return (
unsigned(
r ) ) + ( unsigned(
g ) << 8 ) + (
unsigned(
b ) << 16 ) + (
unsigned(
a ) << 24 ); }
27 static constexpr Color gray() noexcept {
return Color( 127, 127, 127, 255 ); }
28 static constexpr Color red() noexcept {
return Color( 255, 0, 0, 255 ); }
39 if constexpr ( std::is_same_v<T, uint8_t> )
43 else if constexpr ( std::is_integral_v<T> )
45 return val >= 255 ? uint8_t( 255 ) : ( val <= 0 ? uint8_t( 0 ) : uint8_t( val ) );
49 return val >= T( 1 ) ? uint8_t( 255 ) : ( val <= T( 0 ) ? uint8_t( 0 ) : uint8_t( val * 255 ) );
72 if constexpr ( std::is_integral_v<T> )
92 return Color(
r,
g,
b, uint8_t( std::clamp( m *
a, 0.0f , 255.0f ) ) );
98 return a.r ==
b.r &&
a.g ==
b.g &&
a.b ==
b.b &&
a.a ==
b.a;
108 return Color(Vector4i(
a ) + Vector4i(
b ));
113 return Color( Vector4i(
a ) - Vector4i(
b ) );
118 return Color(
a * Vector4f(
b ) );
123 return Color(
a * Vector4f(
b ) );
128 return b * ( 1 /
a );
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
BitSet operator-(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:370
MRMESH_API bool operator==(const BitSet &a, const BitSet &b)
compare that two bit sets have the same set bits (they can be equal even if sizes are distinct but la...
Definition MRCameraOrientationPlugin.h:8
bool operator!=(const Color &a, const Color &b)
Definition MRMesh/MRColor.h:101
Color operator/(const Color &b, float a)
Definition MRMesh/MRColor.h:126
Color operator*(float a, const Color &b)
Definition MRMesh/MRColor.h:116
MRMESH_API Color blend(const Color &front, const Color &back)
Color operator+(const Color &a, const Color &b)
Definition MRMesh/MRColor.h:106
Definition MRMesh/MRColor.h:9
static constexpr Color transparent() noexcept
Definition MRMesh/MRColor.h:34
static constexpr Color green() noexcept
Definition MRMesh/MRColor.h:29
static constexpr Color purple() noexcept
Definition MRMesh/MRColor.h:33
uint8_t a
Definition MRMesh/MRColor.h:10
static constexpr uint8_t valToUint8(T val) noexcept
Definition MRMesh/MRColor.h:37
constexpr Color(const Vector3< T > &vec) noexcept
Definition MRMesh/MRColor.h:54
constexpr Color() noexcept
Definition MRMesh/MRColor.h:12
const uint8_t & operator[](int e) const
Definition MRMesh/MRColor.h:82
Color & operator-=(const Color &other)
Definition MRMesh/MRColor.h:86
static constexpr Color black() noexcept
Definition MRMesh/MRColor.h:26
constexpr Color(int r, int g, int b, int a) noexcept
Definition MRMesh/MRColor.h:14
static constexpr Color yellow() noexcept
Definition MRMesh/MRColor.h:31
constexpr Color(float r, float g, float b) noexcept
Definition MRMesh/MRColor.h:21
static constexpr Color brown() noexcept
Definition MRMesh/MRColor.h:32
uint8_t g
Definition MRMesh/MRColor.h:10
Color & operator+=(const Color &other)
Definition MRMesh/MRColor.h:85
constexpr unsigned int getUInt32() const noexcept
Definition MRMesh/MRColor.h:23
Color & operator/=(float m)
Definition MRMesh/MRColor.h:88
static constexpr Color red() noexcept
Definition MRMesh/MRColor.h:28
uint8_t r
Definition MRMesh/MRColor.h:10
constexpr Color scaledAlpha(float m) const noexcept
Definition MRMesh/MRColor.h:90
static constexpr Color gray() noexcept
Definition MRMesh/MRColor.h:27
static constexpr Color blue() noexcept
Definition MRMesh/MRColor.h:30
uint8_t b
Definition MRMesh/MRColor.h:10
Color(NoInit) noexcept
Definition MRMesh/MRColor.h:13
constexpr Color(float r, float g, float b, float a) noexcept
Definition MRMesh/MRColor.h:16
constexpr Color(const Vector4< T > &vec) noexcept
Definition MRMesh/MRColor.h:62
Color & operator*=(float m)
Definition MRMesh/MRColor.h:87
constexpr Color(int r, int g, int b) noexcept
Definition MRMesh/MRColor.h:15
static constexpr Color white() noexcept
Definition MRMesh/MRColor.h:25
Definition MRMesh/MRMeshFwd.h:90
Definition MRMesh/MRVector3.h:28
Definition MRVector4.h:22