2 using System.Collections.Generic;
5 using DirectOutput.Cab.Out;
6 using DirectOutput.General.Color;
7 using DirectOutput.General;
9 namespace DirectOutput.Cab.Toys.Layer
29 [System.Xml.Serialization.XmlIgnore]
30 public LayerDictionary<RGBAColor> Layers {
get;
private set; }
45 foreach (KeyValuePair<int, RGBAColor> KV
in Layers)
47 int Alpha = KV.Value.Alpha;
50 int NegAlpha = 255 - Alpha;
51 Red = AlphaMappingTable.AlphaMapping[NegAlpha, (int)Red] + AlphaMappingTable.AlphaMapping[Alpha, KV.Value.Red];
52 Green = AlphaMappingTable.AlphaMapping[NegAlpha, (
int)Green] + AlphaMappingTable.AlphaMapping[Alpha, KV.Value.Green];
53 Blue = AlphaMappingTable.AlphaMapping[NegAlpha, (int)Blue] + AlphaMappingTable.AlphaMapping[Alpha, KV.Value.Blue];
57 return new RGBColor((
int)Red, (
int)Green, (
int)Blue);
77 public string OutputNameRed {
get;
set; }
84 public string OutputNameGreen {
get;
set; }
91 public string OutputNameBlue {
get;
set; }
97 private string _FadingCurveName =
"Linear";
98 private Curve FadingCurve = null;
107 public string FadingCurveName
109 get {
return _FadingCurveName; }
110 set { _FadingCurveName = value; }
115 if (Cabinet.
Curves.Contains(FadingCurveName))
117 FadingCurve = Cabinet.
Curves[FadingCurveName];
119 else if (!FadingCurveName.IsNullOrWhiteSpace())
124 Enum.TryParse(FadingCurveName, out T);
125 FadingCurve =
new Curve(T);
130 Cabinet.
Curves.Add(FadingCurveName);
143 private Cabinet _Cabinet;
149 public override void Init(Cabinet Cabinet)
152 InitFadingCurve(Cabinet);
153 InitOutputs(Cabinet);
156 private void InitOutputs(Cabinet Cabinet)
160 _OutputRed = Cabinet.
Outputs[OutputNameRed];
168 _OutputGreen = Cabinet.
Outputs[OutputNameGreen];
176 _OutputBlue = Cabinet.
Outputs[OutputNameBlue];
191 public override void Finish()
207 public override void UpdateOutputs()
211 if (_OutputRed != null)
213 _OutputRed.Value = FadingCurve.MapValue(RGB.
Red);
215 if (_OutputGreen != null)
217 _OutputGreen.Value = FadingCurve.MapValue(RGB.
Green);
219 if (_OutputBlue != null)
221 _OutputBlue.Value = FadingCurve.MapValue(RGB.
Blue);
229 public override void Reset()
232 if (_OutputRed != null)
234 _OutputRed.Value = 0;
236 if (_OutputGreen != null)
238 _OutputGreen.Value = 0;
240 if (_OutputBlue != null)
242 _OutputBlue.Value = 0;
252 Layers =
new LayerDictionary<RGBAColor>();