// fadeoutDuration in seconds private void FadeOutToColor(LEDData frameData, LightZone zones, float fadeoutDuration, HSVColor color) { int frames = (int)Math.Round(fadeoutDuration * FPS); List <Led[]> frameLightArrays = frameData.GetArraysForZones(zones); for (int i = 0; i < frames; i++) { float fadeout = (float)Utils.Scale(i, 0, frames, 0, 1); LEDData newFrame = LEDData.Empty; List <Led[]> newFrameLightArrays = newFrame.GetArraysForZones(zones); for (int j = 0; j < frameLightArrays.Count; j++) { Led[] arrCurrent = frameLightArrays[j]; Led[] arrNew = newFrameLightArrays[j]; for (int k = 0; k < arrCurrent.Length; k++) { Led l = arrCurrent[k]; HSVColor fadedColor; if (color.Equals(HSVColor.Black)) { fadedColor = l.color.FadeToBlackBy(fadeout); } else { fadedColor = l.color.FadeToColorBy(color, fadeout); } arrNew[k].Color(fadedColor); } } SendFrame(newFrame, zones); } }
private void ApplyColorToZones(LEDData frameData, LightZone zones, HSVColor color) { List <Led[]> colArrays = frameData.GetArraysForZones(zones); foreach (Led[] arr in colArrays) { foreach (Led l in arr) { l.Color(color); } } }
public void FadeBetweenTwoColors(LightZone zones, HSVColor col1, HSVColor col2, float rate = 0.15f, float duration = 2) { // TODO: Broken int frames = (int)Math.Round(duration * FPS); for (int i = 0; i < frames; i++) { float currentTime = i / FPS; float sin = (float)Math.Sin(currentTime * rate); HSVColor color = HSVColor.Lerp(col1, col2, sin); LEDData newFrame = LEDData.Empty; List <Led[]> newFrameLightArrays = newFrame.GetArraysForZones(zones); foreach (Led[] arr in newFrameLightArrays) { foreach (Led l in arr) { l.Color(color); } } SendFrame(newFrame, zones); } }