Example #1
0
        /// <summary>
        /// Returns the RGB color from a specific position of the color temperature scale.
        /// </summary>
        /// <param name="y">The vertical position from up to bottom.</param>
        /// <param name="height">Total height of the scale.</param>
        /// <returns></returns>
        public Color PickTemperaturePixelColor(int y, int height)
        {
            if (y <= 6 || height - y <= 6)
            {
                return(Colors.Transparent);
            }

            return(ColorConverters.ColorTemperatue((int)Math.Round((1 - (double)y / height) * 4500 + 2000)));
        }
Example #2
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));
        }