private void GrabHue(Point mouseXY) { // center our coordinate system so the middle is (0,0), and positive Y is facing up float cx = mouseXY.X - radius; float cy = radius - mouseXY.Y; double theta = Math.Atan2(cy, cx); if (theta < 0) { theta += 2 * Math.PI; } hsvcolor.Hue = (int)(theta * radtodeg); color = hsvcolor.ToColorBgra(); OnColorChanged(); }
void hsvupdown_ValueChanged(object sender, EventArgs e) { if (!eventssuspended) { SuspendEvents(); hslider.Value = (float)hupdown.Value / 360f; sslider.Value = (float)supdown.Value / 100f; vslider.Value = (float)vupdown.Value / 100f; HsvColor h = new HsvColor((int)hupdown.Value, (int)supdown.Value, (int)vupdown.Value); ColorBgra c = h.ToColorBgra(); c.A = (byte)aupdown.Value; wheel.Color = c; SetRgbSliders(c); SetHex(c.R, c.G, c.B); ResumeEvents(); } }