Example #1
0
        private void UpdateFromHSL()
        {
            double hue = (double)GetInt(hueTextBox);
            double sat = (double)GetInt(satTextBox) / satmax;
            double lum = (double)GetInt(lumTextBox) / lummax;

            hslColor = new HSColor(hue, sat, lum);
            rgbColor = hslColor.ToRGB(ColorSpace.HSL);
            SetRGBTextBoxes();
            SetGraphics();
            SetColorPanel();
        }
Example #2
0
        private void UpdateFromLumMouse(MouseEventArgs e)
        {
            double newLum = Math.Max(Math.Min(1.0, Y2Lum(e.Y + lumMouseOffset)), 0.0);

            hslColor = new HSColor(hslColor.Hue, hslColor.Sat, newLum);
            rgbColor = hslColor.ToRGB(ColorSpace.HSL);

            SetRGBTextBoxes();
            SetHSLTextBoxes();
            SetColorPanel();

            lumPanel.Invalidate();
            ClearLumMarker();
        }
Example #3
0
        private void UpdateFromBitmapMouse(MouseEventArgs e)
        {
            // Calc cartesian coords
            int x   = e.X - bmMid.X;
            int y   = bmMid.Y - e.Y;
            int rad = (int)Math.Round(Math.Sqrt(x * x + y * y));

            double hue = Math.Atan2(y, x) * RadToAngle;

            if (hue < 0)
            {
                hue = 360 + hue;
            }

            // If rad is greater than bmRad, then must recalc bmX,bmY so that
            // they stay within the circle
            if (rad > bmRad)
            {
                double radRatio = (double)bmRad / (double)rad;
                bmX = (int)Math.Floor(x * radRatio) + bmMid.X;
                bmY = bmMid.Y - (int)Math.Floor(y * radRatio);
                rad = bmRad;
            }
            else
            {
                bmX = e.X;
                bmY = e.Y;
            }

            double sat = rad / (double)bmRad;

            hslColor = new HSColor(hue, sat, hslColor.Val);
            rgbColor = hslColor.ToRGB(ColorSpace.HSL);

            SetRGBTextBoxes();
            SetHSLTextBoxes();
            SetColorPanel();

            bitmapPanel.Invalidate();
            lumPanel.Invalidate();
            ClearLumMarker();
        }