15 constexpr Color() noexcept :
r{ 0 },
g{ 0 },
b{ 0 },
a{ 255 } {}
16 explicit Color( NoInit )
noexcept {}
17 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)} {}
18 constexpr Color(
int r,
int g,
int b ) noexcept :
r{uint8_t(
r)},
g{uint8_t(
g)},
b{uint8_t(
b)},
a{255} {}
19 constexpr Color(
float r,
float g,
float b,
float a ) 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 ) )} {}
26 constexpr unsigned int getUInt32() const noexcept {
return (
unsigned(
r ) ) + ( unsigned(
g ) << 8 ) + (
unsigned(
b ) << 16 ) + (
unsigned(
a ) << 24 ); }
30 static constexpr Color gray() noexcept {
return Color( 127, 127, 127, 255 ); }
31 static constexpr Color red() noexcept {
return Color( 255, 0, 0, 255 ); }
42 if constexpr ( std::is_same_v<T, uint8_t> )
46 else if constexpr ( std::is_integral_v<T> )
48 return val >= 255 ? uint8_t( 255 ) : ( val <= 0 ? uint8_t( 0 ) : uint8_t( val ) );
52 return val >= T( 1 ) ? uint8_t( 255 ) : ( val <= T( 0 ) ? uint8_t( 0 ) : uint8_t( val * 255 ) );
75 if constexpr ( std::is_integral_v<T> )
95 return Color(
r,
g,
b, uint8_t( std::clamp( m *
a, 0.0f , 255.0f ) ) );
101 return a.r ==
b.r &&
a.g ==
b.g &&
a.b ==
b.b &&
a.a ==
b.a;
111 return Color(Vector4i(
a ) + Vector4i(
b ));
116 return Color( Vector4i(
a ) - Vector4i(
b ) );
121 return Color(
a * Vector4f(
b ) );
126 return Color(
a * Vector4f(
b ) );
131 return b * ( 1 /
a );
141struct std::hash<
MR::Color>
143 std::uint32_t operator()(
MR::Color c )
const noexcept
146 static_assert(
sizeof( r ) ==
sizeof( c ) );
147 std::memcpy( &r, &c,
sizeof( r ) );
BitSet operator-(const BitSet &a, const BitSet &b)
Definition MRBitSet.h:457
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...
static constexpr Color transparent() noexcept
Definition MRColor.h:37
static constexpr Color green() noexcept
Definition MRColor.h:32
static constexpr Color purple() noexcept
Definition MRColor.h:36
uint8_t a
Definition MRColor.h:13
static constexpr uint8_t valToUint8(T val) noexcept
Definition MRColor.h:40
constexpr Color(const Vector3< T > &vec) noexcept
Definition MRColor.h:57
constexpr Color() noexcept
Definition MRColor.h:15
const uint8_t & operator[](int e) const
Definition MRColor.h:85
Color & operator-=(const Color &other)
Definition MRColor.h:89
bool operator!=(const Color &a, const Color &b)
Definition MRColor.h:104
static constexpr Color black() noexcept
Definition MRColor.h:29
constexpr Color(int r, int g, int b, int a) noexcept
Definition MRColor.h:17
Color operator/(const Color &b, float a)
Definition MRColor.h:129
Color operator*(float a, const Color &b)
Definition MRColor.h:119
static constexpr Color yellow() noexcept
Definition MRColor.h:34
constexpr Color(float r, float g, float b) noexcept
Definition MRColor.h:24
static constexpr Color brown() noexcept
Definition MRColor.h:35
uint8_t g
Definition MRColor.h:13
Color & operator+=(const Color &other)
Definition MRColor.h:88
constexpr unsigned int getUInt32() const noexcept
Using a separate overload instead of a default argument to produce better C bindings.
Definition MRColor.h:26
Color & operator/=(float m)
Definition MRColor.h:91
static constexpr Color red() noexcept
Definition MRColor.h:31
uint8_t r
Definition MRColor.h:13
constexpr Color scaledAlpha(float m) const noexcept
Definition MRColor.h:93
static constexpr Color gray() noexcept
Definition MRColor.h:30
static constexpr Color blue() noexcept
Definition MRColor.h:33
uint8_t b
Definition MRColor.h:13
Color(NoInit) noexcept
Definition MRColor.h:16
constexpr Color(float r, float g, float b, float a) noexcept
Using a separate overload instead of a default argument to produce better C bindings.
Definition MRColor.h:19
constexpr Color(const Vector4< T > &vec) noexcept
Definition MRColor.h:65
MRMESH_API Color blend(const Color &front, const Color &back)
Color & operator*=(float m)
Definition MRColor.h:90
constexpr Color(int r, int g, int b) noexcept
Definition MRColor.h:18
Color operator+(const Color &a, const Color &b)
Definition MRColor.h:109
static constexpr Color white() noexcept
Definition MRColor.h:28
@ other
Angle, normally float. Measure in radians.
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRVector3.h:33
Definition MRVector4.h:26