Link to home
Create AccountLog in
Avatar of pdering
pdering

asked on

c# color picker on mouse over

I would like a color pallet that contains a blend of many colors.  Then as  I move the mouse over each pixel the individual color is reported (I assume in a  property).  How can  I  do this?
And no  I don't just want to use a typical color dialog box.
ASKER CERTIFIED SOLUTION
Avatar of ckluka
ckluka

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of pdering
pdering

ASKER

the tag was an accident
Avatar of pdering

ASKER

Yes I understand but how do you get each mouse pixel color? Something like this?

Color c = Color(MouseOverR, MouseOverG, MouseOverB)
This is from that same link...

just replace the HSL color stuff with what ever type you need it to be:

void SetColor(PointF mousepoint)
{
    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 < 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);
}