Add Color

This commit is contained in:
Frank A. Krueger 2017-06-18 12:29:23 -07:00
parent 9e402bcb9c
commit 692187e0cb
1 changed files with 26 additions and 0 deletions

26
Ooui/Color.cs Normal file
View File

@ -0,0 +1,26 @@
using System;
namespace Ooui
{
public struct Color
{
public byte R, G, B, A;
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));
}
}
}