Esempio n. 1
0
        void SetColor(PointF mousepoint)
        {
            if (WheelRectangle.Contains(mousepoint) == false)
                return;

            PointF center = Util.Center(ColorWheelRectangle);
            double radius = Radius(ColorWheelRectangle);
            double dx = Math.Abs(mousepoint.X - center.X);
            double dy = Math.Abs(mousepoint.Y - center.Y);
            double angle = Math.Atan(dy / dx) / Math.PI * 180;
            double dist = Math.Pow((Math.Pow(dx, 2) + (Math.Pow(dy, 2))), 0.5);
            double saturation = dist/radius;
            //if (dist > radius + 5) // give 5 pixels slack
            //	return;
            if (dist < 6)
                saturation = 0; // snap to center

            if (mousepoint.X < center.X)
                angle = 180 - angle;
            if (mousepoint.Y > center.Y)
                angle = 360 - angle;

            SelectedHSLColor = new HSLColor(angle, saturation, SelectedHSLColor.Lightness);
        }
Esempio n. 2
0
 void OnWheelColorChanged(object sender, EventArgs e)
 {
     m_selectedColor.Hue = m_colorWheel.SelectedHSLColor.Hue;
     m_selectedColor.Saturation = m_colorWheel.SelectedHSLColor.Saturation;
     SelectedHSLColor = m_selectedColor;
 }
Esempio n. 3
0
 protected override void SetPercent(float percent)
 {
     base.SetPercent(percent);
     m_selectedColor.Lightness = percent / 100;
     SelectedHSLColor = m_selectedColor;
 }
Esempio n. 4
0
 void OnLightnessColorChanged(object sender, EventArgs e)
 {
     m_selectedColor.Lightness = m_colorBar.SelectedHSLColor.Lightness;
     SelectedHSLColor = m_selectedColor;
 }