8public static class HSVUtil
13 return ConvertRgbToHsv((
int)(color.r * 255), (
int)(color.g * 255), (
int)(color.b * 255));
17 public static HsvColor ConvertRgbToHsv(
double r,
double b,
double g)
38 h = 2 + (b - r) / delta;
40 h = 4 + (r - g) / delta;
57 public static Color ConvertHsvToRgb(
double h,
double s,
double v,
float alpha)
60 double r = 0, g = 0, b = 0;
84 q = v * (1.0 - (s * f));
85 t = v * (1.0 - (s * (1.0f - f)));
129 return new Color((
float)r, (
float)g, (
float)b, alpha);
135#endregion ColorUtilities
160 return (
float)
H / 360f;
165 H = (double)value * 360;
202 return "{" +
H.ToString(
"f2") +
"," +
S.ToString(
"f2") +
"," +
V.ToString(
"f2") +
"}";
override string ToString()
HsvColor(double h, double s, double v)
double H
The Hue, ranges between 0 and 360
double S
The saturation, ranges between 0 and 1