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.
And no I don't just want to use a typical color dialog box.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Yes I understand but how do you get each mouse pixel color? Something like this?
Color c = Color(MouseOverR, MouseOverG, MouseOverB)
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(ColorWheelRect angle);
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 );
}
just replace the HSL color stuff with what ever type you need it to be:
void SetColor(PointF mousepoint)
{
PointF center = Util.Center(ColorWheelRect
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
}
ASKER