Browse Source

Clean up colors

Former-commit-id: ef3fb067f37be5af30955604ef8f7e788c060fc8
Former-commit-id: fdf15de4bf1184ae07ffdeb37e0219e960dd9db5
Former-commit-id: 6ab66cdb8fd7f82c38b6ddc5ac11364c09accd97
pull/1/head
James South 10 years ago
parent
commit
493d91c671
  1. 13
      src/ImageProcessorCore/Colors/Color.cs
  2. 43
      src/ImageProcessorCore/Colors/Colorspaces/Bgra32.cs

13
src/ImageProcessorCore/Colors/Color.cs

@ -34,17 +34,6 @@ namespace ImageProcessorCore
/// </summary>
private Vector4 backingVector;
/// <summary>
/// Initializes a new instance of the <see cref="Color"/> struct with the alpha component set to 1.
/// </summary>
/// <param name="r">The red component of this <see cref="Color"/>.</param>
/// <param name="g">The green component of this <see cref="Color"/>.</param>
/// <param name="b">The blue component of this <see cref="Color"/>.</param>
public Color(float r, float g, float b)
: this(r, g, b, 1)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Color"/> struct.
/// </summary>
@ -52,7 +41,7 @@ namespace ImageProcessorCore
/// <param name="g">The green component of this <see cref="Color"/>.</param>
/// <param name="b">The blue component of this <see cref="Color"/>.</param>
/// <param name="a">The alpha component of this <see cref="Color"/>.</param>
public Color(float r, float g, float b, float a)
public Color(float r, float g, float b, float a = 1)
: this()
{
this.backingVector = new Vector4(r, g, b, a);

43
src/ImageProcessorCore/Colors/Colorspaces/Bgra32.cs

@ -24,17 +24,6 @@ namespace ImageProcessorCore
/// </summary>
private Vector4 backingVector;
/// <summary>
/// Initializes a new instance of the <see cref="Bgra32"/> struct.
/// </summary>
/// <param name="b">The blue component of this <see cref="Bgra32"/>.</param>
/// <param name="g">The green component of this <see cref="Bgra32"/>.</param>
/// <param name="r">The red component of this <see cref="Bgra32"/>.</param>
public Bgra32(byte b, byte g, byte r)
: this(b, g, r, 255)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Bgra32"/> struct.
/// </summary>
@ -42,7 +31,7 @@ namespace ImageProcessorCore
/// <param name="g">The green component of this <see cref="Bgra32"/>.</param>
/// <param name="r">The red component of this <see cref="Bgra32"/>.</param>
/// <param name="a">The alpha component of this <see cref="Bgra32"/>.</param>
public Bgra32(byte b, byte g, byte r, byte a)
public Bgra32(byte b, byte g, byte r, byte a = 255)
: this()
{
this.backingVector = Vector4.Clamp(new Vector4(b, g, r, a), Vector4.Zero, new Vector4(255));
@ -129,13 +118,7 @@ namespace ImageProcessorCore
return !left.Equals(right);
}
/// <summary>
/// Indicates whether this instance and a specified object are equal.
/// </summary>
/// <returns>
/// true if <paramref name="obj"/> and this instance are the same type and represent the same value; otherwise, false.
/// </returns>
/// <param name="obj">Another object to compare to. </param>
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (obj is Bgra32)
@ -148,23 +131,13 @@ namespace ImageProcessorCore
return false;
}
/// <summary>
/// Returns the hash code for this instance.
/// </summary>
/// <returns>
/// A 32-bit signed integer that is the hash code for this instance.
/// </returns>
/// <inheritdoc/>
public override int GetHashCode()
{
return GetHashCode(this);
}
/// <summary>
/// Returns the fully qualified type name of this instance.
/// </summary>
/// <returns>
/// A <see cref="T:System.String"/> containing a fully qualified type name.
/// </returns>
/// <inheritdoc/>
public override string ToString()
{
if (this.IsEmpty)
@ -175,13 +148,7 @@ namespace ImageProcessorCore
return $"Bgra32 [ B={this.B}, G={this.G}, R={this.R}, A={this.A} ]";
}
/// <summary>
/// Indicates whether the current object is equal to another object of the same type.
/// </summary>
/// <returns>
/// True if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
/// </returns>
/// <param name="other">An object to compare with this object.</param>
/// <inheritdoc/>
public bool Equals(Bgra32 other)
{
return this.backingVector.Equals(other.backingVector);

Loading…
Cancel
Save