protected override CorsairColor FinalizeColor(CorsairColor color)
        {
            if (Math.Abs(Settings.Gamma - 1f) > float.Epsilon)
                ColorHelper.CorrectGamma(color, Settings.Gamma);

            float lightness = (float)Math.Max((Settings.MinLightness / 100.0), (color.GetHSVValue() * ((double)Brightness < 0.0 ? 0.0f : ((double)Brightness > 1.0 ? 1f : Brightness))));
            byte alpha = (byte)((double)color.A * ((double)Opacity < 0.0 ? 0.0 : ((double)Opacity > 1.0 ? 1.0 : (double)Opacity)));
            
            return ColorHelper.ColorFromHSV(color.GetHSVHue(), color.GetHSVSaturation(), lightness, alpha);
        }
Beispiel #2
0
        /// <summary>
        /// Applies the gamma-correction to the given color. 
        /// </summary>
        /// <param name="color">The color to correct.</param>
        public void ApplyTo(CorsairColor color)
        {
            if (Math.Abs(R - 1f) > float.Epsilon)
                color.R = ColorHelper.GetIntColorFromFloat((float)Math.Pow(color.GetFloatR(), 1.0 / R));

            if (Math.Abs(G - 1f) > float.Epsilon)
                color.G = ColorHelper.GetIntColorFromFloat((float)Math.Pow(color.GetFloatG(), 1.0 / G));

            if (Math.Abs(B - 1f) > float.Epsilon)
                color.B = ColorHelper.GetIntColorFromFloat((float)Math.Pow(color.GetFloatB(), 1.0 / B));
        }
Beispiel #3
0
        /// <summary>
        /// Tests whether the specified object is a <see cref="CorsairColor" /> and is equivalent to this <see cref="CorsairColor" />.
        /// </summary>
        /// <param name="obj">The object to test.</param>
        /// <returns>true if <paramref name="obj" /> is a <see cref="CorsairColor" /> equivalent to this <see cref="CorsairColor" /> ; otherwise, false.</returns>
        public override bool Equals(object obj)
        {
            CorsairColor compareColor = obj as CorsairColor;

            if (ReferenceEquals(compareColor, null))
            {
                return(false);
            }

            if (ReferenceEquals(this, compareColor))
            {
                return(true);
            }

            if (GetType() != compareColor.GetType())
            {
                return(false);
            }

            return((compareColor.A == A) && (compareColor.R == R) && (compareColor.G == G) && (compareColor.B == B));
        }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SolidColorBrush"/> class.
 /// </summary>
 /// <param name="color">The color drawn by the brush.</param>
 public SolidColorBrush(CorsairColor color)
 {
     this.Color = color;
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LedUpateRequest"/> class.
 /// </summary>
 /// <param name="ledId">The id of the led to update.</param>
 /// <param name="color">The requested color of the led.</param>
 public LedUpateRequest(CorsairLedId ledId, CorsairColor color)
 {
     this.LedId = ledId;
     this.Color = color;
 }
Beispiel #6
0
 /// <summary>
 /// Resets the LED back to default
 /// </summary>
 internal void Reset()
 {
     _color = CorsairColor.Transparent;
     RequestedColor = CorsairColor.Transparent;
     IsLocked = false;
 }
Beispiel #7
0
 /// <summary>
 /// Updates the LED to the requested color.
 /// </summary>
 internal void Update()
 {
     _color = RequestedColor;
 }
Beispiel #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GradientStop"/> class.
 /// </summary>
 /// <param name="offset">The percentage offset to place this stop.</param>
 /// <param name="color">The color of the stop.</param>
 public GradientStop(float offset, CorsairColor color)
 {
     this.Offset = offset;
     this.Color = color;
 }
Beispiel #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CorsairColor"/> class by cloning a existing <see cref="CorsairColor"/>.
 /// </summary>
 /// <param name="color">The <see cref="CorsairColor"/> the values are copied from.</param>
 public CorsairColor(CorsairColor color)
     : this(color.A, color.R, color.G, color.B)
 {
 }
Beispiel #10
0
        /// <summary>
        /// Blends two colors.
        /// </summary>
        /// <param name="bg">The background-color.</param>
        /// <param name="fg">The foreground-color</param>
        /// <returns>The resulting color.</returns>
        public static CorsairColor Blend(this CorsairColor bg, CorsairColor fg)
        {
            if (fg.A == 255)
                return fg;

            if (fg.A == 0)
                return bg;

            float resultA = (1f - (1f - fg.GetFloatA()) * (1f - bg.GetFloatA()));
            float resultR = (fg.GetFloatR() * fg.GetFloatA() / resultA + bg.GetFloatR() * bg.GetFloatA() * (1f - fg.GetFloatA()) / resultA);
            float resultG = (fg.GetFloatG() * fg.GetFloatA() / resultA + bg.GetFloatG() * bg.GetFloatA() * (1f - fg.GetFloatA()) / resultA);
            float resultB = (fg.GetFloatB() * fg.GetFloatA() / resultA + bg.GetFloatB() * bg.GetFloatA() * (1f - fg.GetFloatA()) / resultA);
            return CreateColorFromFloat(resultA, resultR, resultG, resultB);
        }
Beispiel #11
0
 /// <summary>
 /// Resets the LED back to default
 /// </summary>
 internal void Reset()
 {
     _color         = CorsairColor.Transparent;
     RequestedColor = CorsairColor.Transparent;
     IsLocked       = false;
 }
Beispiel #12
0
 /// <summary>
 /// Updates the LED to the requested color.
 /// </summary>
 internal void Update()
 {
     _color = RequestedColor;
 }
Beispiel #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LedUpateRequest"/> class.
 /// </summary>
 /// <param name="ledId">The id of the led to update.</param>
 /// <param name="color">The requested color of the led.</param>
 public LedUpateRequest(CorsairLedId ledId, CorsairColor color)
 {
     this.LedId = ledId;
     this.Color = color;
 }