void setNuanceByPosition(Point p) { double a, b, d; a = 0.5773502691896258d * (yBottom - p.Y); // (yB - p.Y) / sqrt(3) b = xCenter + halfSide - p.X - a; d = sideLength - b; if (d == 0) d = 0.00001; HSV = new ColorHSV( Hue, Math.Max(0, Math.Min(1, 2 * a / d)), Math.Max(0, Math.Min(1, d / sideLength)) ); }
/// <summary> /// Convert an HSV color to RGB. /// </summary> /// <param name="HSV">HSV Color.</param> /// <returns>RGB Color</returns> public static Color ToRGB(ColorHSV HSV) { return ToRGB(HSV.H, HSV.S, HSV.V); }