mirror of
https://github.com/hyprwm/hyprgraphics.git
synced 2025-12-20 13:20:04 +01:00
static identity
This commit is contained in:
parent
82ca4247a0
commit
a7979cd179
2 changed files with 16 additions and 11 deletions
|
|
@ -62,12 +62,14 @@ namespace Hyprgraphics {
|
|||
CMatrix3() = default;
|
||||
CMatrix3(const std::array<std::array<double, 3>, 3>& values);
|
||||
|
||||
CMatrix3 invert();
|
||||
CMatrix3 invert() const;
|
||||
CColor::XYZ operator*(const CColor::XYZ& xyz) const;
|
||||
CMatrix3 operator*(const CMatrix3& other) const;
|
||||
|
||||
const std::array<std::array<double, 3>, 3>& mat();
|
||||
|
||||
static const CMatrix3& identity();
|
||||
|
||||
private:
|
||||
std::array<std::array<double, 3>, 3> m = {
|
||||
0, 0, 0, //
|
||||
|
|
@ -76,14 +78,8 @@ namespace Hyprgraphics {
|
|||
};
|
||||
};
|
||||
|
||||
const CMatrix3 Identity3 = CMatrix3(std::array<std::array<double, 3>, 3>{
|
||||
1, 0, 0, //
|
||||
0, 1, 0, //
|
||||
0, 0, 1, //
|
||||
});
|
||||
|
||||
CColor::XYZ xy2xyz(const CColor::xy& xy);
|
||||
CMatrix3 adaptWhite(const CColor::xy& src, const CColor::xy& dst);
|
||||
CColor::XYZ xy2xyz(const CColor::xy& xy);
|
||||
CMatrix3 adaptWhite(const CColor::xy& src, const CColor::xy& dst);
|
||||
|
||||
struct SPCPRimaries {
|
||||
CColor::xy red, green, blue, white;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ static double hueToRgb(double p, double q, double t) {
|
|||
|
||||
Hyprgraphics::CMatrix3::CMatrix3(const std::array<std::array<double, 3>, 3>& values) : m(values) {}
|
||||
|
||||
CMatrix3 Hyprgraphics::CMatrix3::invert() {
|
||||
CMatrix3 Hyprgraphics::CMatrix3::invert() const {
|
||||
double invDet = 1 /
|
||||
(0 //
|
||||
+ m[0][0] * (m[1][1] * m[2][2] - m[2][1] * m[1][2]) //
|
||||
|
|
@ -67,6 +67,15 @@ const std::array<std::array<double, 3>, 3>& Hyprgraphics::CMatrix3::mat() {
|
|||
return m;
|
||||
};
|
||||
|
||||
const CMatrix3& CMatrix3::identity() {
|
||||
static const CMatrix3 Identity3 = CMatrix3(std::array<std::array<double, 3>, 3>{
|
||||
1, 0, 0, //
|
||||
0, 1, 0, //
|
||||
0, 0, 1, //
|
||||
});
|
||||
return Identity3;
|
||||
}
|
||||
|
||||
CColor::XYZ Hyprgraphics::xy2xyz(const CColor::xy& xy) {
|
||||
if (xy.y == 0.0)
|
||||
return {0.0, 0.0, 0.0};
|
||||
|
|
@ -84,7 +93,7 @@ CMatrix3 BradfordInv = Bradford.invert();
|
|||
|
||||
CMatrix3 Hyprgraphics::adaptWhite(const CColor::xy& src, const CColor::xy& dst) {
|
||||
if (src == dst)
|
||||
return Identity3;
|
||||
return CMatrix3::identity();
|
||||
|
||||
const auto srcXYZ = xy2xyz(src);
|
||||
const auto dstXYZ = xy2xyz(dst);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue