Luski.Net/Luski.net/Structures/Public/Color.cs

60 lines
1.0 KiB
C#
Raw Normal View History

using System;
namespace Luski.net.Structures.Public;
2024-08-27 10:57:22 -04:00
public struct Color
{
public Color(string servercol)
{
2024-08-27 10:57:22 -04:00
byte[] t = Convert.FromHexString(servercol);
r = t[0];
g = t[1];
b = t[2];
a = t[3];
}
public static bool operator ==(Color a, Color b)
{
return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a;
}
public static bool operator !=(Color a, Color b)
{
return a.r != b.r || a.g != b.g || a.b != b.b || a.a != b.a;
}
public Color(byte R, byte G, byte B, byte A)
{
2024-08-27 10:57:22 -04:00
r = R;
g = G;
b = B;
a = A;
}
2024-03-20 23:18:34 -04:00
public string ToDatabaseStr()
{
2024-08-27 10:57:22 -04:00
return Convert.ToHexString(new []{r,g,b,a});
}
2024-03-20 23:18:34 -04:00
2024-08-27 10:57:22 -04:00
private byte r;
private byte g;
private byte b;
private byte a;
public byte A
{
2024-08-27 10:57:22 -04:00
get => a;
}
public byte R
{
2024-08-27 10:57:22 -04:00
get => r;
}
public byte G
{
2024-08-27 10:57:22 -04:00
get => g;
}
public byte B
{
2024-08-27 10:57:22 -04:00
get => b;
}
}