29 #ifndef __Thea_ColorL8_hpp__ 30 #define __Thea_ColorL8_hpp__ 64 ColorL8(
ColorL const & other);
67 uint8
value()
const {
return val; }
73 uint8
const *
data()
const {
return &val; }
76 uint8 *
data() {
return &val; }
79 template <
typename IntegerT> uint8
const &
operator[](IntegerT channel)
const 81 debugAssertM(channel == 0,
"ColorL8: Channel must be 0");
86 template <
typename IntegerT> uint8 &
operator[](IntegerT channel)
88 debugAssertM(channel == 0,
"ColorL8: Channel must be 0");
93 void fill(uint8 v) { val = v; }
98 return ColorL8((uint8)std::min(255, (
int)val + (
int)other.val));
104 return ColorL8((uint8)std::max(0, (
int)val - (
int)other.val));
122 *
this = *
this + other;
129 *
this = *
this - other;
136 *
this = *
this * other;
143 *
this = *
this / other;
148 ColorL8
max(ColorL8
const & other)
const 150 return ColorL8(std::max(val, other.val));
154 ColorL8
min(ColorL8
const & other)
const 156 return ColorL8(std::min(val, other.val));
160 static ColorL8
const &
zero() {
static ColorL8
const col(0);
return col; }
ColorL operator*(Real lhs, ColorL const &rhs)
Multiply by a scalar.
ColorL8 & operator/=(Real other)
Divide by a scalar and assign.
ColorL8 & operator*=(Real other)
Multiply by a scalar and assign.
std::string toString(char const *s)
Convert a C-string to a std::string object, returning an empty string if the input is a null pointer...
ColorL8 operator*(Real other) const
Multiply by a scalar.
uint8 & operator[](IntegerT channel)
Array-style channel access.
Root namespace for the Thea library.
ColorL8 min(ColorL8 const &other) const
Get the minimum of two color values.
Monochrome luminance value represented as a single byte value in [0, 255], with automatic scaling by ...
static ColorL8 const & zero()
Color with zero luminance (black).
uint8 const * data() const
Get the address of the color value.
ColorL8()
Default constructor, initializes color to 0.
T clamp(T const &x, U const &lo, V const &hi)
Clamp a number to lie in the range [lo, hi] (inclusive).
ColorL8 & operator-=(ColorL8 const &other)
Subtract-and-assign.
uint8 value_type
The numerical type of the luminance value.
ColorL8 & operator+=(ColorL8 const &other)
Add-and-assign.
Monochrome luminance value in [0, 1], with automatic scaling by 255 when switching between integer (C...
uint8 & value()
The value of the color.
uint8 const & operator[](IntegerT channel) const
Array-style channel access.
ColorL8(uint8 v)
Initializing constructor.
A color with four floating-point channels: red, green and blue, each in [0, 1].
void fill(uint8 v)
Set the luminance value, for consistency with multi-channel colors.
float round(float x)
Round a real number to the nearest integer using the lrintf() routine.
ColorL8 operator/(Real other) const
Divide by a scalar.
ColorL8 operator+(ColorL8 const &other) const
Addition operator.
ColorL8 max(ColorL8 const &other) const
Get the maximum of two color values.
uint8 * data()
Get the address of the color value.
uint8 value() const
The value of the color.
ColorL8 operator-(ColorL8 const &other) const
Subtraction operator.
void debugAssertM(CondT const &test, MessageT const &msg)
Check if a test condition is true, and immediately abort the program with an error code if not...