예제 #1
0
        /// <summary>
        /// Draws this control in the style hue.
        /// </summary>
        /// <param name="map">The map to update.</param>
        private void DrawStyleHue(ref ColorMap map)
        {
            var hslStart = new HSL();
            var hslEnd   = new HSL();

            hslStart.H = this.hsl.H;
            hslEnd.H   = this.hsl.H;

            hslStart.S = 0;
            hslEnd.S   = 1;

            for (var y = 0; y < map.Height; y++)
            {
                hslStart.L = (float)y / map.Height;
                hslEnd.L   = hslStart.L;

                var rgbStart = AdobeColors.HSLToRGB(hslStart);
                var rgbEnd   = AdobeColors.HSLToRGB(hslEnd);

                for (var x = 0; x < map.Width; x++)
                {
                    var lerpValue = 1 - (x / (float)map.Width);

                    // System.Diagnostics.Debug.WriteLine(lerpValue);
                    var rgbValue = AdobeColors.Lerp(rgbStart, rgbEnd, lerpValue);
                    map.Set(x, y, rgbValue);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Draws this control in the style saturation.
        /// </summary>
        /// <param name="map">The map to update.</param>
        private void DrawStyleSaturation(ref ColorMap map)
        {
            var hslStart = new HSL();
            var hslEnd   = new HSL();

            hslStart.S = this.hsl.S;
            hslEnd.S   = this.hsl.S;
            hslStart.L = 1.0;
            hslEnd.L   = 0.0;

            for (var x = 0; x < map.Width; x++)
            {
                for (var y = 0; y < map.Height; y++)
                {
                    // Calculate Hue at this line (Saturation and Luminance are constant)
                    hslStart.H = (double)x / map.Width;
                    hslEnd.H   = hslStart.H;

                    var rgbStart = AdobeColors.HSLToRGB(hslStart);
                    var rgbEnd   = AdobeColors.HSLToRGB(hslEnd);

                    var lerpValue = y / map.Height;

                    var rgbValue = AdobeColors.Lerp(rgbStart, rgbEnd, lerpValue);
                    map.Set(x, y, rgbValue);
                }
            }
        }