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); }
/// <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)); }
/// <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)); }
/// <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; }
/// <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; }
/// <summary> /// Resets the LED back to default /// </summary> internal void Reset() { _color = CorsairColor.Transparent; RequestedColor = CorsairColor.Transparent; IsLocked = false; }
/// <summary> /// Updates the LED to the requested color. /// </summary> internal void Update() { _color = RequestedColor; }
/// <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; }
/// <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) { }
/// <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); }
/// <summary> /// Resets the LED back to default /// </summary> internal void Reset() { _color = CorsairColor.Transparent; RequestedColor = CorsairColor.Transparent; IsLocked = false; }
/// <summary> /// Updates the LED to the requested color. /// </summary> internal void Update() { _color = RequestedColor; }
/// <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; }