14 using Vector4::Vector4;
21 constexpr explicit Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
22 :
Vector4{(float)r / 255.0f, (
float)g / 255.0f, (float)b / 255.0f, (
float)a / 255.0f}
26 static constexpr auto Red() ->
Color {
return Color{1.0f, 0.0, 0.0f, 1.0f}; }
27 static constexpr auto Green() ->
Color {
return Color{0.0f, 1.0, 0.0f, 1.0f}; }
28 static constexpr auto Blue() ->
Color {
return Color{0.0f, 0.0, 1.0f, 1.0f}; }
29 static constexpr auto White() ->
Color {
return Color{1.0f, 1.0, 1.0f, 1.0f}; }
30 static constexpr auto Black() ->
Color {
return Color{0.0f, 0.0, 0.0f, 1.0f}; }
31 static constexpr auto Transparent() ->
Color {
return Color{0.0f, 0.0, 0.0f, 0.0f}; }
33 constexpr auto R() ->
float& {
return x; }
34 constexpr auto G() ->
float& {
return y; }
35 constexpr auto B() ->
float& {
return z; }
36 constexpr auto A() ->
float& {
return w; }
37 constexpr auto R()
const ->
const float& {
return x; }
38 constexpr auto G()
const ->
const float& {
return y; }
39 constexpr auto B()
const ->
const float& {
return z; }
40 constexpr auto A()
const ->
const float& {
return w; }
55 : start{solidColor}, end{solidColor}
60 : start{from}, end{to}
65 constexpr auto Lerp(
float t)
const noexcept ->
Color
68 nc::Lerp(start.R(), end.R(), t),
69 nc::Lerp(start.G(), end.G(), t),
70 nc::Lerp(start.B(), end.B(), t),
71 nc::Lerp(start.A(), end.A(), t)
76 constexpr auto Lerp(
float tColor,
float tAlpha)
const noexcept ->
Color
79 nc::Lerp(start.R(), end.R(), tColor),
80 nc::Lerp(start.G(), end.G(), tColor),
81 nc::Lerp(start.B(), end.B(), tColor),
82 nc::Lerp(start.A(), end.A(), tAlpha)
86 friend constexpr auto operator==(
const Gradient& lhs,
const Gradient& rhs) ->
bool
88 return lhs.start == rhs.start && lhs.end == rhs.end;
Four component color.
Definition: Color.h:13
Gradient between two Colors.
Definition: Color.h:45
constexpr auto Lerp(float t) const noexcept -> Color
Select a Color between start and end.
Definition: Color.h:65
constexpr auto Lerp(float tColor, float tAlpha) const noexcept -> Color
Select a Color between start and end with distinct color and alpha factors.
Definition: Color.h:76
A four component vector.
Definition: Vector.h:48