protected override CorsairColor FinalizeColor(CorsairColor color) { // Apply our gamma-correction ((GammaCorrection)Settings.Gamma).ApplyTo(color); 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> /// Finalizes the color by appliing the overall brightness and opacity.<br/> /// This method should always be the last call of a <see cref="GetColorAtPoint" /> implementation. /// If you overwrite this method please make sure that you never return the same color-object twice to prevent reference-issues! /// </summary> /// <param name="color">The color to finalize.</param> /// <returns>The finalized color.</returns> protected virtual CorsairColor FinalizeColor(CorsairColor color) { foreach (IColorCorrection colorCorrection in ColorCorrections) { colorCorrection.ApplyTo(color); } // Since we use HSV to calculate there is no way to make a color 'brighter' than 100% // Be carefull with the naming: Since we use HSV the correct term is 'value' but outside we call it 'brightness' // THIS IS NOT A HSB CALCULATION!!! float finalBrightness = color.GetHSVValue() * (Brightness < 0 ? 0 : (Brightness > 1f ? 1f : Brightness)); byte finalAlpha = (byte)(color.A * (Opacity < 0 ? 0 : (Opacity > 1f ? 1f : Opacity))); return(ColorHelper.ColorFromHSV(color.GetHSVHue(), color.GetHSVSaturation(), finalBrightness, finalAlpha)); }