本文整理汇总了C#中Color.GetHue方法的典型用法代码示例。如果您正苦于以下问题:C# Color.GetHue方法的具体用法?C# Color.GetHue怎么用?C# Color.GetHue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color.GetHue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ColorToHsv
public static void ColorToHsv(Color color, out double hue, out double saturation, out double value)
{
int max = Math.Max(color.R, Math.Max(color.G, color.B));
int min = Math.Min(color.R, Math.Min(color.G, color.B));
hue = color.GetHue();
saturation = (max == 0) ? 0 : 1d - (1d * min / max);
value = max / 255d;
}
示例2: ColorToHSV
public static void ColorToHSV(Color color, out float hue, out float saturation, out float value)
{
float max = Math.Max(color.r, Math.Max(color.g, color.b));
float min = Math.Min(color.r, Math.Min(color.g, color.b));
hue = color.GetHue();
saturation = (max == 0) ? 0 : 1f - (1f * min / max);
value = max;
}
示例3: SimilarColors
private static bool SimilarColors(Color colorOne, Color colorTwo)
{
if (Math.Abs(colorOne.GetHue()-colorTwo.GetHue()) <= 36)
{
//Console.WriteLine("Hue");
return true;
}
if (Math.Abs(colorOne.GetBrightness()-colorTwo.GetBrightness()) <= .1)
{
//Console.WriteLine("Hue");
return true;
}
if (Math.Abs(colorOne.GetSaturation()-colorTwo.GetSaturation()) <= .1)
{
//Console.WriteLine("Hue");
return true;
}
return false;
}
示例4: UpdateHsb
private void UpdateHsb(Color value) {
Hue = (int)value.GetHue();
var brightness = value.GetBrightness();
Brightness = (int)(brightness * 100);
var saturation = value.GetSaturation();
Saturation = (int)(saturation * 100);
UpdateThumbPosition();
}
示例5: HSLColor
public HSLColor(Color color)
{
Hue = color.GetHue();
Saturation = color.GetSaturation();
Lightness = color.GetBrightness();
}
示例6: ClosestColorHsb
/// <summary>
/// Weighed distance using hue, saturation and brightness.
/// </summary>
/// <param name="colors"></param>
/// <param name="target"></param>
/// <returns></returns>
public static int ClosestColorHsb(List<Color> colors, Color target)
{
float hue1 = target.GetHue();
var num1 = ColorNum(target);
var diffs = colors.Select(n => Math.Abs(ColorNum(n) - num1) +
GetHueDistance(n.GetHue(), hue1));
var diffMin = diffs.Min(x => x);
return diffs.ToList().FindIndex(n => n == diffMin);
}
示例7: ClosestColorHue
/// <summary>
/// Closest match for hues only.
/// </summary>
/// <param name="colors"></param>
/// <param name="target"></param>
/// <returns></returns>
public static int ClosestColorHue(List<Color> colors, Color target)
{
var hue1 = target.GetHue();
var diffs = colors.Select(n => GetHueDistance(n.GetHue(), hue1));
var diffMin = diffs.Min(n => n);
return diffs.ToList().FindIndex(n => n == diffMin);
}