/// <summary>
        ///     Loads the color picker.
        /// </summary>
        /// <param name="onSelectColor">
        ///     The select color delegate.
        /// </param>
        /// <param name="color">
        ///     The color.
        /// </param>
        public static void Load(OnSelectColor onSelectColor, Color color)
        {
            OnChangeColor = onSelectColor;
            sColor = color;
            sHue = ((HSLColor)color).Hue;
            sSaturation = ((HSLColor)color).Saturation;

            LuminositySlider.Percent = (float)sColor.Luminosity / 100f;
            AlphaSlider.Percent = color.A / 255f;
            X = (Drawing.Width - BackgroundSprite.Width) / 2;
            Y = (Drawing.Height - BackgroundSprite.Height) / 2;

            Visible = true;
            UpdateLuminosityBitmap(color);
            UpdateOpacityBitmap(color);
            initialColor = color;
        }
        /// <summary>
        ///     Updates the opacity bitmap.
        /// </summary>
        /// <param name="color">
        ///     The color.
        /// </param>
        /// <param name="force">
        ///     Indicates whether to force update.
        /// </param>
        private static void UpdateOpacityBitmap(HSLColor color, bool force = false)
        {
            if (Utils.TickCount - LastBitmapUpdate[1] < 100 && !force)
            {
                return;
            }

            LastBitmapUpdate[1] = Utils.TickCount;
            color.Luminosity = 0d;

            for (var y = 0; y < OpacityBitmap.Height; y++)
            {
                for (var x = 0; x < OpacityBitmap.Width; x++)
                {
                    OpacityBitmap.SetPixel(x, y, color);
                }

                color.Luminosity += 40d / LuminityBitmap.Height;
            }

            if (OpacitySprite != null)
            {
                OpacitySprite.UpdateTextureBitmap(OpacityBitmap);
            }
        }
Esempio n. 3
0
 /// <summary>
 ///     Gets the temp2.
 /// </summary>
 /// <param name="hslColor">
 ///     Color of the HSL.
 /// </param>
 /// <returns>
 ///     The temp2.
 /// </returns>
 private static double GetTemp2(HSLColor hslColor)
 {
     return (hslColor.luminosity < 0.5)
                ? hslColor.luminosity * (1.0 + hslColor.saturation)
                : hslColor.luminosity + hslColor.saturation - (hslColor.luminosity * hslColor.saturation);
 }