This commit is contained in:
ShrlAlgo
2025-07-11 09:20:23 +08:00
parent c7b104f44f
commit 4d35cadb56
840 changed files with 102347 additions and 11595 deletions

57
WPFDark/DoubleColor.cs Normal file
View File

@@ -0,0 +1,57 @@
using System.Runtime.CompilerServices;
using System.Windows.Media;
using WPFDark.Internals;
namespace WPFDark
{
public struct DoubleColor
{
public bool Equals(DoubleColor other)
{
return R.Equals(other.R) && G.Equals(other.G) && B.Equals(other.B) && A.Equals(other.A);
}
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj))
return false;
return obj is DoubleColor other && Equals(other);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode()
// ReSharper disable NonReadonlyMemberInGetHashCode
=> HashCodeMaker.To32(HashCodeMaker.Make(R, G, B, A));
// ReSharper restore NonReadonlyMemberInGetHashCode
public static readonly DoubleColor Zero = new DoubleColor
{
R = 0.0,
G = 0.0,
B = 0.0,
A = 0.0
};
public double R { get; set; }
public double G { get; set; }
public double B { get; set; }
public double A { get; set; }
public Color Color =>
Color.FromArgb(
(byte) (NumberHelper.Clamp01(A) * 0xFF),
(byte) (NumberHelper.Clamp01(R) * 0xFF),
(byte) (NumberHelper.Clamp01(G) * 0xFF),
(byte) (NumberHelper.Clamp01(B) * 0xFF)
);
public ByteColor ByteColor =>
new ByteColor(
(byte) (NumberHelper.Clamp01(A) * 0xFF),
(byte) (NumberHelper.Clamp01(R) * 0xFF),
(byte) (NumberHelper.Clamp01(G) * 0xFF),
(byte) (NumberHelper.Clamp01(B) * 0xFF)
);
}
}