📷 A modern, cross-platform, 2D Graphics library for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

111 lines
4.0 KiB

// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RoundedCornerLayer.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Encapsulates the properties required to add rounded corners to an image.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Imaging
{
/// <summary>
/// Encapsulates the properties required to add rounded corners to an image.
/// </summary>
public class RoundedCornerLayer
{
/// <summary>
/// Initializes a new instance of the <see cref="RoundedCornerLayer"/> class.
/// </summary>
/// <param name="radius">
/// The radius at which the corner will be done.
/// </param>
/// <param name="topLeft">
/// Set if top left is rounded
/// </param>
/// <param name="topRight">
/// Set if top right is rounded
/// </param>
/// <param name="bottomLeft">
/// Set if bottom left is rounded
/// </param>
/// <param name="bottomRight">
/// Set if bottom right is rounded
/// </param>
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
/// <summary>
/// Gets or sets the radius of the corners.
/// </summary>
public int Radius { get; set; }
/// <summary>
/// Gets or sets a value indicating whether top left corners are to be added.
/// </summary>
public bool TopLeft { get; set; }
/// <summary>
/// Gets or sets a value indicating whether top right corners are to be added.
/// </summary>
public bool TopRight { get; set; }
/// <summary>
/// Gets or sets a value indicating whether bottom left corners are to be added.
/// </summary>
public bool BottomLeft { get; set; }
/// <summary>
/// Gets or sets a value indicating whether bottom right corners are to be added.
/// </summary>
public bool BottomRight { get; set; }
#endregion
/// <summary>
/// Returns a value that indicates whether the specified object is an
/// <see cref="RoundedCornerLayer"/> object that is equivalent to
/// this <see cref="RoundedCornerLayer"/> object.
/// </summary>
/// <param name="obj">
/// The object to test.
/// </param>
/// <returns>
/// True if the given object is an <see cref="RoundedCornerLayer"/> object that is equivalent to
/// this <see cref="RoundedCornerLayer"/> object; otherwise, false.
/// </returns>
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;
}
/// <summary>
/// Returns a hash code value that represents this object.
/// </summary>
/// <returns>
/// A hash code that represents this object.
/// </returns>
public override int GetHashCode()
{
return this.Radius.GetHashCode() +
this.TopLeft.GetHashCode() + this.TopRight.GetHashCode() +
this.BottomLeft.GetHashCode() + this.BottomRight.GetHashCode();
}
}
}