WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
RGBAMatrixPlasmaEffect.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
6 
7 namespace DirectOutput.FX.MatrixFX
8 {
14  {
15 
16  private RGBAColor _ActiveColor1 = new RGBAColor(0x00, 0x00, 0xff, 0xff);
17 
24  public RGBAColor ActiveColor1
25  {
26  get { return _ActiveColor1; }
27  set { _ActiveColor1 = value; }
28  }
29 
30 
31  private RGBAColor _ActiveColor2 = new RGBAColor(0x80, 0x80, 0x00, 0xff);
32 
39  public RGBAColor ActiveColor2
40  {
41  get { return _ActiveColor2; }
42  set { _ActiveColor2 = value; }
43  }
44 
45 
46  private RGBAColor _InactiveColor = new RGBAColor(0, 0, 0, 0);
47 
54  public RGBAColor InactiveColor
55  {
56  get { return _InactiveColor; }
57  set { _InactiveColor = value; }
58  }
59 
60 
61  protected override RGBAColor GetEffectValue(int TriggerValue, double Time, double Value, double X, double Y)
62  {
63 
64  double BlendVal = (Math.Sin(Value * Math.PI * 2 + Time) + 1) / 2;
65  RGBAColor Blended = new RGBAColor(
66  (int)(BlendVal * ActiveColor1.Red + (1 - BlendVal) * ActiveColor2.Red),
67  (int)(BlendVal * ActiveColor1.Green + (1 - BlendVal) * ActiveColor2.Green),
68  (int)(BlendVal * ActiveColor1.Blue + (1 - BlendVal) * ActiveColor2.Blue),
69  (int)((BlendVal * ActiveColor1.Alpha + (1 - BlendVal) * ActiveColor2.Alpha) * Value)
70  );
71 
72 
73  RGBAColor D = new RGBAColor();
74 
75  int V = TriggerValue.Limit(0, 255);
76  D.Red = InactiveColor.Red + (int)((float)(Blended.Red - InactiveColor.Red) * V / 255).Limit(0, 255);
77  D.Green = InactiveColor.Green + (int)((float)(Blended.Green - InactiveColor.Green) * V / 255).Limit(0, 255);
78  D.Blue = InactiveColor.Blue + (int)((float)(Blended.Blue - InactiveColor.Blue) * V / 255).Limit(0, 255);
79  D.Alpha = InactiveColor.Alpha + (int)((float)(Blended.Alpha - InactiveColor.Alpha) * V / 255).Limit(0, 255);
80  return D;
81 
82 
83  //return new RGBAColor(00, 0, 255, (int)(Value / 255 * TriggerValue));
84 
85 
86  // return new RGBAColor((byte)((Math.Sin(Value / 255 * Math.PI) + 1) * 127.5), (byte)((Math.Cos(Value / 255 * Math.PI) + 1) * 127.5), (byte)((Math.Sin(Time * 22.987) + 1) * 127.5), 255);
87 
88  // return new RGBAColor((byte)((Math.Sin(Value / 255 * Math.PI) + 1) * 127.5), (byte)((Math.Cos(Value / 255 * Math.PI) + 1) * 127.5), (byte)((Math.Sin(Time * 22.987) + 1) * 127.5), (int)(Value / 255 * TriggerValue));
89 
90  // return new RGBAColor((byte)((Math.Sin(X * 3.27 + Y * 1.789 + Time * 24.321) + 1) * 127.5), (byte)((Math.Sin(X * 1.27 + Y * 2.659 + Time * 23.371) + 1) * 127.5), (byte)((Math.Sin(X * 2.1798+ Y*2.001327 + Time * 22.987) + 1) * 127.5), (int)(Value / 255 * TriggerValue));
91  }
92  }
93 }
This class stores information on colors used for toys and effects (e.g. RGBLed).
Definition: RGBAColor.cs:14
int Red
Brightness for Red.
Definition: RGBAColor.cs:27
Displayes a classical plasma effect on a RGBA matrix/ledstrip array. For more details on the math of ...
int Green
Brightness for Green.
Definition: RGBAColor.cs:40
int Blue
Brightness for Blue.
Definition: RGBAColor.cs:52
int Alpha
Alpha value for the color.
Definition: RGBAColor.cs:64
The namespace DirectOutput.General contains classes for general use.
override RGBAColor GetEffectValue(int TriggerValue, double Time, double Value, double X, double Y)