Ooui-tws-port/Ooui/Color.cs

42 lines
1.0 KiB
C#
Raw Normal View History

2017-06-18 19:29:23 +00:00
using System;
2017-11-09 09:38:19 +00:00
using StyleValue = System.Object;
2017-06-18 19:29:23 +00:00
namespace Ooui
{
public struct Color
{
public byte R, G, B, A;
2017-11-10 00:09:48 +00:00
public Color (byte r, byte g, byte b, byte a)
2017-11-09 09:38:19 +00:00
{
R = r;
G = g;
B = b;
A = a;
}
2017-06-18 19:29:23 +00:00
public double Red {
get => R / 255.0;
set => R = value >= 1.0 ? (byte)255 : ((value <= 0.0) ? (byte)0 : (byte)(value * 255.0 + 0.5));
}
public double Green {
get => G / 255.0;
set => G = value >= 1.0 ? (byte)255 : ((value <= 0.0) ? (byte)0 : (byte)(value * 255.0 + 0.5));
}
public double Blue {
get => B / 255.0;
set => B = value >= 1.0 ? (byte)255 : ((value <= 0.0) ? (byte)0 : (byte)(value * 255.0 + 0.5));
}
public double Alpha {
get => A / 255.0;
set => A = value >= 1.0 ? (byte)255 : ((value <= 0.0) ? (byte)0 : (byte)(value * 255.0 + 0.5));
}
2017-11-09 09:38:19 +00:00
public static Color FromStyleValue (StyleValue styleColor)
{
2017-11-10 00:09:48 +00:00
return Colors.Clear;
2017-11-09 09:38:19 +00:00
}
}
2017-06-18 19:29:23 +00:00
}