コード例 #1
0
 private void VU_Update_RandomColor()
 {
     if (VU_Rainbow_Solid_Color_Change_Count > MathUtilities.ConvertRange (Audio_Average_Intensity, 0, 1, VU_Rainbow_Solid_Color_Change_Max_Delay, VU_Rainbow_Solid_Color_Change_Min_Delay)) {
         VU_Rainbow_Solid_Color_Change_Count = 0;
         VU_RandomColor = RandomColorGenerator.GetRandomColor ();
         VU_ShiftSpeed = Audio_Average_Intensity * VU_ShiftSpeed_Multiplier;
     } else {
         VU_Rainbow_Solid_Color_Change_Count ++;
     }
     //			if (ReactiveSystem.Processing_Show_Analysis) {
     //				Console.WriteLine ("Intensity delta ceiling: " + Math.Round (MathUtilities.ConvertRange (VU_Average_Intensity, 0, 1, VU_Rainbow_Solid_Color_Change_Max_Delay, VU_Rainbow_Solid_Color_Change_Min_Delay), 3).ToString ().PadRight (5) + "  Shift speed: " + Math.Round (VU_ShiftSpeed, 3).ToString ().PadRight (5).ToString () + "  Current color: " + VU_RandomColor.Name);
     //			}
 }
コード例 #2
0
ファイル: LED.cs プロジェクト: digitalcircuit/actinic
        /// <summary>
        /// Blends the current color with the new one.
        /// </summary>
        /// <param name="SelectedColor">Selected color.</param>
        /// <param name="Subtractive">If set to <c>true</c> the new color reduces the brightness and hue of the current.</param>
        /// <param name="Opacity">Amount this color influences the current color.</param>
        public void BlendColor(Actinic.Color SelectedColor, bool Subtractive, double Opacity)
        {
            if (Opacity < 0 || Opacity > 1)
                throw new ArgumentOutOfRangeException ("Opacity", "Opacity must be a value between 0 and 1.");

            // Reduce the intensity of the new color
            Actinic.Color opacifiedColor = new Actinic.Color ((byte)(SelectedColor.R * Opacity),
                                                              (byte)(SelectedColor.G * Opacity),
                                                              (byte)(SelectedColor.B * Opacity),
                                                              (byte)(SelectedColor.Brightness * Opacity));
            if (Subtractive) {
                // Reduce these colors from the current
                R = (byte)Math.Max (R - opacifiedColor.R, 0);
                G = (byte)Math.Max (G - opacifiedColor.G, 0);
                B = (byte)Math.Max (B - opacifiedColor.B, 0);
                Brightness = (byte)Math.Max (Brightness - opacifiedColor.Brightness, 0);
            } else {
                // Take the brightest colors
                R = Math.Max (R, opacifiedColor.R);
                G = Math.Max (G, opacifiedColor.G);
                B = Math.Max (B, opacifiedColor.B);
                Brightness = Math.Max (Brightness, opacifiedColor.Brightness);
            }
        }
コード例 #3
0
        private void UpdateColorsFromTime()
        {
            int currentTime = (DateTime.Now.Hour * 60) + (DateTime.Now.Minute);
            TimeColor = TimeColorGradient.GetColor (currentTime);

            switch (AnimationStyle) {
            case Style.Moderate:
                // Set brightness for all based on the current time of day
                TimeColor_Brightness = TimeColor.Brightness;
                break;
            case Style.Soft:
                // Dim the themed-brightness (themed-brightness isn't always COLOR_MAX) using a ratio of the style
                TimeColor_Brightness = (byte)(Math.Max (Math.Min ((int)(TimeColor.Brightness * ((double)Styled_BrightBrightness / LightSystem.Brightness_MAX)), LightSystem.Brightness_MAX), LightSystem.Brightness_MIN_VISIBLE));
                // ...and don't allow something brighter than Color_MAX, or dimmer than minimum-visible
                break;
            default:
                // Override the themed-brightness with the style, i.e. bright
                TimeColor_Brightness = Styled_BrightBrightness;
                break;
            }

            //Console.WriteLine ("Current time: {0}:{1}  Current color (R, G, B, Brightness):  {2}, {3}, {4}, {5}", currentTime / 60, currentTime % 60, TimeColor.R, TimeColor.G, TimeColor.B, TimeColor.Brightness)
        }