Browse Source

Add back HsvColor.FromHsv()

pull/7951/head
robloo 4 years ago
parent
commit
3527baaefa
  1. 4
      src/Avalonia.Visuals/Media/Color.cs
  2. 16
      src/Avalonia.Visuals/Media/HsvColor.cs

4
src/Avalonia.Visuals/Media/Color.cs

@ -278,7 +278,7 @@ namespace Avalonia.Media
/// <returns>The HSV equivalent color.</returns>
public HsvColor ToHsv()
{
// Use the by-channel conversion method directly for performance
// Use the by-component conversion method directly for performance
// Don't use the HsvColor(Color) constructor to avoid an extra HsvColor
return HsvColor.FromRgb(R, G, B, A);
}
@ -289,11 +289,13 @@ namespace Avalonia.Media
return A == other.A && R == other.R && G == other.G && B == other.B;
}
/// <inheritdoc/>
public override bool Equals(object? obj)
{
return obj is Color other && Equals(other);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked

16
src/Avalonia.Visuals/Media/HsvColor.cs

@ -309,6 +309,22 @@ namespace Avalonia.Media
return new HsvColor(a, h, s, v);
}
/// <summary>
/// Creates a new <see cref="HsvColor"/> from individual color component values.
/// </summary>
/// <remarks>
/// This exists for symmetry with the <see cref="Color"/> struct; however, the
/// appropriate constructor should commonly be used instead.
/// </remarks>
/// <param name="h">The Hue component in the range from 0..360.</param>
/// <param name="s">The Saturation component in the range from 0..1.</param>
/// <param name="v">The Value component in the range from 0..1.</param>
/// <returns>A new <see cref="HsvColor"/> built from the individual color component values.</returns>
public static HsvColor FromHsv(double h, double s, double v)
{
return new HsvColor(1.0, h, s, v);
}
/// <summary>
/// Converts the given HSV color to it's RGB color equivalent.
/// </summary>

Loading…
Cancel
Save