2 using System.Collections.Generic;
5 using System.Xml.Serialization;
29 set { _Red = value.Limit(0, 255); }
41 get {
return _Green; }
42 set { _Green = value.Limit(0, 255); }
54 set { _Blue = value.Limit(0, 255); }
65 get {
return _Alpha; }
66 set { _Alpha = value.Limit(0, 255); }
83 public string HexColor
87 return "#{0:X2}{1:X2}{2:X2}{3:X2}".Build(
new object[] { Red, Green, Blue, Alpha });
101 return new RGBAColor(Red, Green, Blue, Alpha);
115 public bool SetColor(
int Red,
int Green,
int Blue,
int Alpha)
137 this.Alpha = (Red + Green + Blue > 0 ? 255 : 0);
169 if ((Color.Length == 8 && Color.IsHexString()) || (Color.Length == 9 && Color.StartsWith(
"#") && Color.IsHexString(1)))
172 if (Color.StartsWith(
"#"))
180 SetColor(Color.Substring(0 + Offset, 2).HexToInt(), Color.Substring(2 + Offset, 2).HexToInt(), Color.Substring(4 + Offset, 2).HexToInt(), Color.Substring(6 + Offset, 2).HexToInt());
184 if ((Color.Length == 6 && Color.IsHexString()) || (Color.Length == 7 && Color.StartsWith(
"#") && Color.IsHexString(1)))
187 if (Color.StartsWith(
"#"))
195 SetColor(Color.Substring(0 + Offset, 2).HexToInt(), Color.Substring(2 + Offset, 2).HexToInt(), Color.Substring(4 + Offset, 2).HexToInt());
199 string[] SplitColors = Color.Split(
',');
200 if (SplitColors.Length == 3)
202 bool ColorsOK =
true;
203 foreach (
string C
in SplitColors)
212 SetColor(
int.Parse(SplitColors[0]),
int.Parse(SplitColors[1]),
int.Parse(SplitColors[2]));
216 else if (SplitColors.Length == 4)
218 bool ColorsOK =
true;
219 foreach (
string C
in SplitColors)
228 SetColor(
int.Parse(SplitColors[0]),
int.Parse(SplitColors[1]),
int.Parse(SplitColors[2]),
int.Parse(SplitColors[3]));
250 public RGBAColor(
int BrightnessRed,
int BrightnessGreen,
int BrightnessBlue)
252 SetColor(BrightnessRed, BrightnessGreen, BrightnessBlue);
262 public RGBAColor(
int BrightnessRed,
int BrightnessGreen,
int BrightnessBlue,
int Alpha)
264 SetColor(BrightnessRed, BrightnessGreen, BrightnessBlue, Alpha);
bool SetColor(int Red, int Green, int Blue)
Sets the RGB components of the Color. The Alpha value is set to 0 if all color components are set to...
RGBAColor(int BrightnessRed, int BrightnessGreen, int BrightnessBlue, int Alpha)
Initializes a new instance of the RGBAColor class.
This class stores information on colors used for toys and effects (e.g. RGBLed).
int Red
Brightness for Red.
int Green
Brightness for Green.
RGBAColor(int BrightnessRed, int BrightnessGreen, int BrightnessBlue)
Initializes a new instance of the RGBAColor class. If all color components are set to 0...
RGBAColor GetRGBAColor()
Gets a new RGBAColor instance with the same color values.
This class stores information on RGB colors used for toys and effects (e.g. RGBLed).
bool SetColor(RGBColor Color)
Sets the RGB components of the RGBAColor. The Alpha value is set to 0 if all color components are se...
RGBAColor Clone()
Clones this instance.
int Blue
Brightness for Blue.
bool SetColor(int Red, int Green, int Blue, int Alpha)
Sets the RGBA components of the Color.
bool SetColor(string Color)
Sets the RGBA components of the Color. The parameter string Color ist first parsed for hexadecimal ...
The namespace DirectOutput.General contains classes for general use.
RGBAColor(string Color)
Initializes a new instance of the RGBAColor class. The parameter string Color is first parsed for h...
RGBAColor(RGBColor RGBColor)
Initializes a new instance of the RGBAColor class. The Alpha value is set to 0 if all color component...