2023-08-21 10:58:17 -04:00
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace Luski.net.Structures.Public;
|
|
|
|
|
2024-08-27 10:57:22 -04:00
|
|
|
public struct Color
|
2023-08-21 10:58:17 -04:00
|
|
|
{
|
|
|
|
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;
|
2023-08-21 10:58:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2023-08-21 10:58:17 -04:00
|
|
|
}
|
|
|
|
|
2024-03-20 23:18:34 -04:00
|
|
|
public string ToDatabaseStr()
|
2023-08-21 10:58:17 -04:00
|
|
|
{
|
2024-08-27 10:57:22 -04:00
|
|
|
return Convert.ToHexString(new []{r,g,b,a});
|
2023-08-21 10:58:17 -04:00
|
|
|
}
|
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;
|
2023-08-21 10:58:17 -04:00
|
|
|
|
|
|
|
public byte A
|
|
|
|
{
|
2024-08-27 10:57:22 -04:00
|
|
|
get => a;
|
2023-08-21 10:58:17 -04:00
|
|
|
}
|
|
|
|
public byte R
|
|
|
|
{
|
2024-08-27 10:57:22 -04:00
|
|
|
get => r;
|
2023-08-21 10:58:17 -04:00
|
|
|
}
|
|
|
|
public byte G
|
|
|
|
{
|
2024-08-27 10:57:22 -04:00
|
|
|
get => g;
|
2023-08-21 10:58:17 -04:00
|
|
|
}
|
|
|
|
public byte B
|
|
|
|
{
|
2024-08-27 10:57:22 -04:00
|
|
|
get => b;
|
2023-08-21 10:58:17 -04:00
|
|
|
}
|
|
|
|
}
|