Ejemplo n.º 1
0
        /// <summary>
        /// Returns the RGB color from a specific position of the saturation scale.
        /// </summary>
        /// <param name="y">The vertical position from up to bottom.</param>
        /// <param name="height">Total height of the scale.</param>
        /// <param name="hue">Current HUE of the saturation scale.</param>
        /// <returns></returns>
        public Color PickSaturationPixelColor(int y, int height, double hue)
        {
            if (y <= 6 || height - y <= 6)
            {
                return(Colors.Transparent);
            }

            return(ColorConverters.HueSaturation(hue == 360 ? 0 : hue / 360 * (2 * Math.PI),
                                                 1 - ((double)y - 6) / (height - 12)));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the RGB color from a specific position of the HUE scale.
        /// </summary>
        /// <param name="y">The vertical position from up to bottom.</param>
        /// <param name="height">Total height of the scale.</param>
        /// <param name="sat">Current saturation of the hue scale.</param>
        /// <returns></returns>
        public Color PickHuePixelColor(int y, int height, double sat)
        {
            if (y <= 6 || height - y <= 6)
            {
                return(Colors.Transparent);
            }

            return(ColorConverters.HueSaturation(2 * Math.PI - ((double)y - 6) / (height - 12) * (2 * Math.PI),
                                                 sat / 100));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns the RGB color from a specific position of the outside wheel.
        /// </summary>
        /// <param name="x">The horizontal position from left to right.</param>
        /// <param name="y">The vertical position from up to bottom.</param>
        /// <param name="outerRadius">Outer radius of the outside wheel.</param>
        /// <param name="innerRadius">Inner radius of the outside wheel.</param>
        /// <returns></returns>
        public Color PickOutsideWheelPixelColor(int x, int y, int outerRadius, int innerRadius)
        {
            var distanceFromCenter = Math.Sqrt(Math.Pow(x - outerRadius, 2) + Math.Pow(y - outerRadius, 2));

            if (distanceFromCenter > outerRadius || distanceFromCenter < innerRadius - 2)
            {
                return(Colors.Transparent);
            }

            var angle = Math.Atan2(y - outerRadius, x - outerRadius) + Math.PI / 2;

            if (angle < 0)
            {
                angle += 2 * Math.PI;
            }

            return(ColorConverters.HueSaturation(
                       Math.Round(angle / ((double)1 / 18 * Math.PI), MidpointRounding.AwayFromZero) *
                       ((double)1 / 18 * Math.PI), 1));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns the RGB color from a specific position of the main wheel.
        /// </summary>
        /// <param name="x">The horizontal position from left to right.</param>
        /// <param name="y">The vertical position from up to bottom.</param>
        /// <param name="radius">The radius from the wheel.</param>
        /// <param name="colorTemperature">Color wheel mode.</param>
        /// <returns></returns>
        public Color PickWheelPixelColor(int x, int y, int radius, bool colorTemperature)
        {
            if (colorTemperature)
            {
                return(ColorConverters.ColorTemperatue((int)Math.Round((1 - (double)y / (2 * radius)) * 4500 + 2000)));
            }

            var distanceFromCenter = Math.Sqrt(Math.Pow(x - radius, 2) + Math.Pow(y - radius, 2));

            if (distanceFromCenter > radius)
            {
                return(Colors.Transparent);
            }

            var angle = Math.Atan2(y - radius, x - radius) + Math.PI / 2;

            if (angle < 0)
            {
                angle += 2 * Math.PI;
            }

            return(ColorConverters.HueSaturation(angle, distanceFromCenter / radius));
        }