Merge remote-tracking branch 'origin/master'
# Conflicts: # src/Color4.cpp
This commit is contained in:
@@ -158,29 +158,29 @@ public:
|
||||
static Color4 Lerp(const Color4& lhs, const Color4& rhs, float t);
|
||||
|
||||
/// Alternative to Lerp which does not normalize color channels before and after interpolation.
|
||||
Color4 Lerp2(const Color4& rhs, float t) const;
|
||||
[[nodiscard]] Color4 Lerp2(const Color4& rhs, float t) const;
|
||||
/// Alternative to Lerp which does not normalize color channels before and after interpolation.
|
||||
static Color4 Lerp2(const Color4& lhs, const Color4& rhs, float t);
|
||||
|
||||
Color4 LerpByHSVA(const Color4& rhs, float t) const;
|
||||
[[nodiscard]] Color4 LerpByHSVA(const Color4& rhs, float t) const;
|
||||
|
||||
std::string ToHex() const;
|
||||
std::string ToHexA() const;
|
||||
[[nodiscard]] std::string ToHex() const;
|
||||
[[nodiscard]] std::string ToHexA() const;
|
||||
|
||||
u8 RedChannel() const;
|
||||
u8 GreenChannel() const;
|
||||
u8 BlueChannel() const;
|
||||
u8 AlphaChannel() const;
|
||||
[[nodiscard]] u8 RedChannel() const;
|
||||
[[nodiscard]] u8 GreenChannel() const;
|
||||
[[nodiscard]] u8 BlueChannel() const;
|
||||
[[nodiscard]] u8 AlphaChannel() const;
|
||||
|
||||
u8 R() const;
|
||||
u8 G() const;
|
||||
u8 B() const;
|
||||
u8 A() const;
|
||||
[[nodiscard]] u8 R() const;
|
||||
[[nodiscard]] u8 G() const;
|
||||
[[nodiscard]] u8 B() const;
|
||||
[[nodiscard]] u8 A() const;
|
||||
|
||||
float RedChannelNormalized() const;
|
||||
float GreenChannelNormalized() const;
|
||||
float BlueChannelNormalized() const;
|
||||
float AlphaChannelNormalized() const;
|
||||
[[nodiscard]] float RedChannelNormalized() const;
|
||||
[[nodiscard]] float GreenChannelNormalized() const;
|
||||
[[nodiscard]] float BlueChannelNormalized() const;
|
||||
[[nodiscard]] float AlphaChannelNormalized() const;
|
||||
|
||||
[[nodiscard]] float RN() const;
|
||||
[[nodiscard]] float GN() const;
|
||||
@@ -190,14 +190,12 @@ public:
|
||||
u8* ptr();
|
||||
[[nodiscard]] const u8* ptr() const;
|
||||
|
||||
HSV ToHSV() const;
|
||||
[[nodiscard]] HSV ToHSV() const;
|
||||
|
||||
HSVA ToHSVA() const;
|
||||
[[nodiscard]] HSVA ToHSVA() const;
|
||||
|
||||
HSL ToHSL() const
|
||||
{
|
||||
|
||||
}
|
||||
HSL ToHSL() const;
|
||||
HSLA ToHSLA() const;
|
||||
|
||||
LCH ToLCH() const {
|
||||
|
||||
|
@@ -1,6 +1,4 @@
|
||||
#include <Color4.hpp>
|
||||
#include <format>
|
||||
|
||||
|
||||
std::vector<Color4> list;
|
||||
|
||||
@@ -250,3 +248,47 @@ HSVA Color4::ToHSVA() const {
|
||||
auto hsv = ToHSV();
|
||||
return {hsv.h, hsv.s, hsv.v, AN()};
|
||||
}
|
||||
|
||||
HSL Color4::ToHSL() const
|
||||
{
|
||||
float rn = RN();
|
||||
float gn = GN();
|
||||
float bn = BN();
|
||||
|
||||
float max = std::max(std::max(rn, gn), bn);
|
||||
float min = std::min(std::min(rn, gn), bn);
|
||||
|
||||
float delta = max - min;
|
||||
|
||||
float L = (min + max) / 2.f;
|
||||
float S = 0;
|
||||
|
||||
if (max == min)
|
||||
S = 0;
|
||||
if (L > 0.5f)
|
||||
S = (delta) * (2.f - max - min);
|
||||
if (L <= 0.5f)
|
||||
S = (max - min) / (max + min);
|
||||
|
||||
float H = 0;
|
||||
|
||||
if (rn == max)
|
||||
H = (gn - bn) / (delta);
|
||||
if (gn == max)
|
||||
H = 2.f + (bn-rn) / (max-min);
|
||||
if (bn == max)
|
||||
H = 4.f + (rn-gn) / (max-min);
|
||||
|
||||
H *= 60;
|
||||
|
||||
if (H < 0.f)
|
||||
H += 360.f;
|
||||
|
||||
return {H,S,L};
|
||||
}
|
||||
|
||||
HSLA Color4::ToHSLA() const
|
||||
{
|
||||
HSL hsl = ToHSL();
|
||||
return {hsl.h, hsl.s, hsl.l, AN()};
|
||||
}
|
||||
|
Reference in New Issue
Block a user