// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
//
//
// Encapsulates the properties required to add rounded corners to an image.
//
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Imaging
{
///
/// Encapsulates the properties required to add rounded corners to an image.
///
public class RoundedCornerLayer
{
///
/// Initializes a new instance of the class.
///
///
/// The radius at which the corner will be rounded.
///
///
/// Set if top left is rounded
///
///
/// Set if top right is rounded
///
///
/// Set if bottom left is rounded
///
///
/// Set if bottom right is rounded
///
public RoundedCornerLayer(int radius, bool topLeft = true, bool topRight = true, bool bottomLeft = true, bool bottomRight = true)
{
this.Radius = radius;
this.TopLeft = topLeft;
this.TopRight = topRight;
this.BottomLeft = bottomLeft;
this.BottomRight = bottomRight;
}
#region Properties
///
/// Gets or sets the radius of the corners.
///
public int Radius { get; set; }
///
/// Gets or sets a value indicating whether top left corners are to be added.
///
public bool TopLeft { get; set; }
///
/// Gets or sets a value indicating whether top right corners are to be added.
///
public bool TopRight { get; set; }
///
/// Gets or sets a value indicating whether bottom left corners are to be added.
///
public bool BottomLeft { get; set; }
///
/// Gets or sets a value indicating whether bottom right corners are to be added.
///
public bool BottomRight { get; set; }
#endregion
///
/// Returns a value that indicates whether the specified object is an
/// object that is equivalent to
/// this object.
///
///
/// The object to test.
///
///
/// True if the given object is an object that is equivalent to
/// this object; otherwise, false.
///
public override bool Equals(object obj)
{
RoundedCornerLayer rounded = obj as RoundedCornerLayer;
if (rounded == null)
{
return false;
}
return this.Radius == rounded.Radius
&& this.TopLeft == rounded.TopLeft && this.TopRight == rounded.TopRight
&& this.BottomLeft == rounded.BottomLeft && this.BottomRight == rounded.BottomRight;
}
///
/// Returns the hash code for this instance.
///
///
/// A 32-bit signed integer that is the hash code for this instance.
///
public override int GetHashCode()
{
unchecked
{
int hashCode = this.Radius;
hashCode = (hashCode * 397) ^ this.TopLeft.GetHashCode();
hashCode = (hashCode * 397) ^ this.TopRight.GetHashCode();
hashCode = (hashCode * 397) ^ this.BottomLeft.GetHashCode();
hashCode = (hashCode * 397) ^ this.BottomRight.GetHashCode();
return hashCode;
}
}
}
}