12 constexpr Color() noexcept :
r{ 0 },
g{ 0 },
b{ 0 },
a{ 255 } {}
14 constexpr Color(
int r,
int g,
int b,
int a = 255 ) noexcept :
19 constexpr Color(
float r,
float g,
float b,
float a = 1 ) noexcept :
20 r{
r > 1 ? uint8_t( 255 ) : (
r < 0 ? uint8_t( 0 ) : uint8_t(
r * 255 ) )},
21 g{
g > 1 ? uint8_t( 255 ) : (
g < 0 ? uint8_t( 0 ) : uint8_t(
g * 255 ) )},
22 b{
b > 1 ? uint8_t( 255 ) : (
b < 0 ? uint8_t( 0 ) : uint8_t(
b * 255 ) )},
23 a{
a > 1 ? uint8_t( 255 ) : (
a < 0 ? uint8_t( 0 ) : uint8_t(
a * 255 ) )}{}
25 constexpr unsigned int getUInt32() const noexcept {
return (
unsigned(
r ) ) + ( unsigned(
g ) << 8 ) + (
unsigned(
b ) << 16 ) + (
unsigned(
a ) << 24 ); }
29 static constexpr Color gray() noexcept {
return Color( 127, 127, 127, 255 ); }
30 static constexpr Color red() noexcept {
return Color( 255, 0, 0, 255 ); }
41 if constexpr ( std::is_same_v<T, uint8_t> )
45 else if constexpr ( std::is_integral_v<T> )
47 return val >= 255 ? uint8_t( 255 ) : ( val <= 0 ? uint8_t( 0 ) : uint8_t( val ) );
51 return val >= T( 1 ) ? uint8_t( 255 ) : ( val <= T( 0 ) ? uint8_t( 0 ) : uint8_t( val * 255 ) );
74 if constexpr ( std::is_integral_v<T> )
94 return Color(
r,
g,
b, uint8_t( std::clamp( m *
a, 0.0f , 255.0f ) ) );
100 return a.r ==
b.r &&
a.g ==
b.g &&
a.b ==
b.b &&
a.a ==
b.a;
110 return Color(Vector4i(
a ) + Vector4i(
b ));
115 return Color( Vector4i(
a ) - Vector4i(
b ) );
120 return Color(
a * Vector4f(
b ) );
125 return Color(
a * Vector4f(
b ) );
130 return b * ( 1 /
a );
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
BitSet operator-(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:325
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...
bool operator!=(const SetBitIteratorT< T > &a, const SetBitIteratorT< T > &b)
Definition MRMesh/MRBitSet.h:259
Definition MRCameraOrientationPlugin.h:7
Color operator/(const Color &b, float a)
Definition MRColor.h:128
Color operator*(float a, const Color &b)
Definition MRColor.h:118
MRMESH_API Color blend(const Color &front, const Color &back)
Color operator+(const Color &a, const Color &b)
Definition MRColor.h:108
static constexpr Color transparent() noexcept
Definition MRColor.h:36
static constexpr Color green() noexcept
Definition MRColor.h:31
static constexpr Color purple() noexcept
Definition MRColor.h:35
uint8_t a
Definition MRColor.h:10
static constexpr uint8_t valToUint8(T val) noexcept
Definition MRColor.h:39
constexpr Color(const Vector3< T > &vec) noexcept
Definition MRColor.h:56
constexpr Color() noexcept
Definition MRColor.h:12
const uint8_t & operator[](int e) const
Definition MRColor.h:84
Color & operator-=(const Color &other)
Definition MRColor.h:88
static constexpr Color black() noexcept
Definition MRColor.h:28
constexpr Color(float r, float g, float b, float a=1) noexcept
Definition MRColor.h:19
static constexpr Color yellow() noexcept
Definition MRColor.h:33
static constexpr Color brown() noexcept
Definition MRColor.h:34
uint8_t g
Definition MRColor.h:10
Color & operator+=(const Color &other)
Definition MRColor.h:87
constexpr unsigned int getUInt32() const noexcept
Definition MRColor.h:25
Color & operator/=(float m)
Definition MRColor.h:90
static constexpr Color red() noexcept
Definition MRColor.h:30
uint8_t r
Definition MRColor.h:10
constexpr Color(int r, int g, int b, int a=255) noexcept
Definition MRColor.h:14
constexpr Color scaledAlpha(float m) const noexcept
Definition MRColor.h:92
static constexpr Color gray() noexcept
Definition MRColor.h:29
static constexpr Color blue() noexcept
Definition MRColor.h:32
uint8_t b
Definition MRColor.h:10
Color(NoInit) noexcept
Definition MRColor.h:13
constexpr Color(const Vector4< T > &vec) noexcept
Definition MRColor.h:64
Color & operator*=(float m)
Definition MRColor.h:89
static constexpr Color white() noexcept
Definition MRColor.h:27
Definition MRMesh/MRMeshFwd.h:56
Definition MRMesh/MRVector3.h:19
Definition MRVector4.h:13