Esempio n. 1
0
 public void SetColor(Actinic.Color SelectedColor)
 {
     R = SelectedColor.R;
     G = SelectedColor.G;
     B = SelectedColor.B;
     Brightness = SelectedColor.Brightness;
 }
Esempio n. 2
0
 /// <summary>
 /// Blends the current color with the new one.
 /// </summary>
 /// <param name="SelectedColor">Selected color.</param>
 /// <param name="BlendMode">Mode for blending colors together.</param>
 public void BlendColor(Actinic.Color SelectedColor, Actinic.LED.BlendingStyle BlendMode)
 {
     switch (BlendMode) {
     case LED.BlendingStyle.Combine:
         // Take the brightest colors
         R = Math.Max (R, SelectedColor.R);
         G = Math.Max (G, SelectedColor.G);
         B = Math.Max (B, SelectedColor.B);
         Brightness = Math.Max (Brightness, SelectedColor.Brightness);
         break;
     case LED.BlendingStyle.Favor:
         if (SelectedColor.HasNoEffect == false) {
             // Overwrite the original with the new layer
             // Brightness controls the amount overriden
             double override_amount = MathUtilities.ConvertRange ((double)SelectedColor.Brightness, (double)LightSystem.Brightness_MIN, (double)LightSystem.Brightness_MAX, 0, 1);
             R = ((byte)Math.Min(((SelectedColor.R * override_amount) + (R * (1 - override_amount))), LightSystem.Color_MAX));
             G = ((byte)Math.Min(((SelectedColor.G * override_amount) + (G * (1 - override_amount))), LightSystem.Color_MAX));
             B = ((byte)Math.Min(((SelectedColor.B * override_amount) + (B * (1 - override_amount))), LightSystem.Color_MAX));
             Brightness = ((byte)Math.Min(((SelectedColor.Brightness * override_amount) + (Brightness * (1 - override_amount))), LightSystem.Color_MAX));
         }
         break;
     case LED.BlendingStyle.Mask:
         if (SelectedColor.HasNoEffect == false) {
             // Don't override empty LEDs
             // Don't directly set (use .Clone() or value-by-value), for by-reference improperly overrides the LED values when multiple 'replace' mode layers exist
             R = SelectedColor.R;
             G = SelectedColor.G;
             B = SelectedColor.B;
             Brightness = SelectedColor.Brightness;
         }
         break;
     case LED.BlendingStyle.Replace:
             // Override even with empty LEDs
             // Don't directly set (use .Clone() or value-by-value), for by-reference improperly overrides the LED values when multiple 'replace' mode layers exist
             R = SelectedColor.R;
             G = SelectedColor.G;
             B = SelectedColor.B;
             Brightness = SelectedColor.Brightness;
         break;
     case LED.BlendingStyle.Sum:
         // Sum the colors together without exceeding the maximum
         R = (byte)Math.Min (R + SelectedColor.R, LightSystem.Color_MAX);
         G = (byte)Math.Min (G + SelectedColor.G, LightSystem.Color_MAX);
         B = (byte)Math.Min (B + SelectedColor.B, LightSystem.Color_MAX);
         Brightness = (byte)Math.Min (Brightness + SelectedColor.Brightness, LightSystem.Brightness_MAX);
         break;
     default:
         throw new ArgumentException ("Unexpected blending mode {0}", BlendMode.ToString ());
     }
 }
Esempio n. 3
0
        /// <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);
            }
        }
Esempio n. 4
0
 private static void FillLights_Color(LED_Queue QueueToModify, Actinic.Color SelectedColor, bool ApplyNow, bool SkipAnimationQueue)
 {
     FillLights_Color (QueueToModify, SelectedColor.R, SelectedColor.G, SelectedColor.B, ApplyNow, SkipAnimationQueue);
 }
Esempio n. 5
0
 private static void FillLights_Color(LED_Queue QueueToModify, Actinic.Color SelectedColor, bool ApplyNow)
 {
     FillLights_Color (QueueToModify, SelectedColor, ApplyNow, false);
 }
Esempio n. 6
0
 private static void FillLights_Color(LED_Queue QueueToModify, Actinic.Color SelectedColor)
 {
     FillLights_Color (QueueToModify, SelectedColor, true);
 }