本文整理汇总了C#中Color.ToHSV方法的典型用法代码示例。如果您正苦于以下问题:C# Color.ToHSV方法的具体用法?C# Color.ToHSV怎么用?C# Color.ToHSV使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color.ToHSV方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Contains
public override bool Contains(Color colour)
{
bool hsv = false;
bool rgb = false;
HSV h = colour.ToHSV();
if ((h.H > 0 & h.H < 35 & h.S > 0.23d & h.S < 0.68) | Contains(h))
hsv = true;
rgb = skinColourLabels[colour.R, colour.G, colour.B];
return rgb | hsv;
}
示例2: SetColor
/// <summary>
/// Sets the selected color.
/// </summary>
/// <param name="value">Value to set.</param>
/// <param name="onlyHue">Deetrmines whether to only set H value (not SV).</param>
public void SetColor(Color value, bool onlyHue) /*true*/
{
HSV hsv = value.ToHSV();
m_Hue = hsv.h;
if (!onlyHue)
{
m_CursorPos.X = (int)(hsv.s * Width);
m_CursorPos.Y = (int)((1 - hsv.v) * Height);
}
Invalidate();
if (ColorChanged != null)
ColorChanged.Invoke(this);
}
示例3: SetColor
private void SetColor(Color color)
{
HSV hsv = color.ToHSV();
m_SelectedDist = (int)(hsv.h / 360 * Height);
if (ColorChanged != null)
ColorChanged.Invoke(this, EventArgs.Empty);
}
示例4: HSV
public HSV(Color c)
{
this = c.ToHSV();
}
示例5: GetLightColors
/// <summary>
/// This is a helper method that sets the light's colors based on the color passed in
/// </summary>
public static void GetLightColors(out Color ambient, out Color front, out Color back, Color color)
{
ColorHSV hsv = color.ToHSV();
//<AmbientLight x:Name="ambientLight" Color="#696969" />
//<DirectionalLight x:Name="frontDirectional" Color="#FFFFFF" Direction="-1,-1,-1" />
//<DirectionalLight x:Name="backDirectional" Color="#303030" Direction="1,1,1" />
ambient = UtilityWPF.HSVtoRGB(color.A, hsv.H, hsv.S, hsv.V * .41d);
front = color;
back = UtilityWPF.HSVtoRGB(color.A, hsv.H, hsv.S, hsv.V * .19d);
}
示例6: Rainbowify
/// <summary>
/// Make a rainbow from the start color, shifting the hue until it reaches the end hue. (Returns a list of Colors).
/// </summary>
/// <param name="startColor">Start color.</param>
/// <param name="endColor">Hue to stop shifting at (will only use the hue of this color, not value or saturation).</param>
/// <param name="length">Desired length of the list.</param>
public static List<Color> Rainbowify(Color startColor, Color endColor, int length)
{
List<Color> rainbow = new List<Color>();
float startHue = startColor.ToHSV().h;
float endHue = endColor.ToHSV().h;
if (endHue < startHue) {
endHue += 360f;
}
float degreesPerStep = (endHue - startHue);
degreesPerStep /= (float)length - 1;
rainbow.Add(startColor);
ColorHSV colorHSV = startColor.ToHSV();
for (int i = 0; i < length - 1; i++) {
colorHSV.ShiftHue(degreesPerStep);
rainbow.Add(colorHSV.ToColor());
}
return rainbow;
}
示例7: MakeGradientHSV
/// <summary>
/// Make a gradient between two colors using HSV (Returns a list of colors blended from startColor to endColor).
/// </summary>
/// <returns>A list of colors blended from startColor to endColor.</returns>
/// <param name="startColor">Start color.</param>
/// <param name="endColor">End color.</param>
/// <param name="blendColors>Number of blended colors in the middle (returned list's length will be this value plus two).</param>
public static List<Color> MakeGradientHSV(Color startColor, Color endColor, int blendColors)
{
List<Color> gradient = new List<Color>();
float startHue = startColor.ToHSV().h;
float endHue = endColor.ToHSV().h;
float startSat = startColor.ToHSV().s;
float endSat = endColor.ToHSV().s;
float startVal = startColor.ToHSV().v;
float endVal = endColor.ToHSV().v;
float degreesPerStep = (endHue - startHue);
if (degreesPerStep > 180f) {
degreesPerStep = degreesPerStep - 360f;
}
if (degreesPerStep < -180f) {
degreesPerStep = degreesPerStep + 360f;
}
float saturationPerStep = (endSat - startSat);
float valuePerStep = (endVal - startVal);
degreesPerStep /= (float)(blendColors + 1);
saturationPerStep /= (float)(blendColors + 1);
valuePerStep /= (float)(blendColors + 1);
gradient.Add(startColor);
ColorHSV colorHSV = startColor.ToHSV();
for (int i = 0; i < blendColors; i++) {
colorHSV.ShiftHue(degreesPerStep);
colorHSV.s += saturationPerStep;
colorHSV.v += valuePerStep;
gradient.Add(colorHSV.ToColor());
}
gradient.Add(endColor);
return gradient;
}
示例8: SetColor
/// <summary>
/// Sets the selected color.
/// </summary>
/// <param name="value">Value to set.</param>
/// <param name="onlyHue">Deetrmines whether to only set H value (not SV).</param>
public void SetColor(Color value, bool onlyHue = true)
{
HSV hsv = value.ToHSV();
m_Hue = hsv.h;
if (!onlyHue)
{
m_CursorPos.X = (int)(hsv.s * Width);
m_CursorPos.Y = (int)((1 - hsv.v) * Height);
}
Invalidate();
ColorChanged?.Invoke(this, EventArgs.Empty);
}