2018-11-30 02:41:06 +00:00
using System ;
2018-12-04 13:45:09 +00:00
namespace RecrownedAthenaeum.DataTypes
2018-11-30 02:41:06 +00:00
{
2019-01-14 07:26:46 +00:00
/// <summary>
/// Holds a width and height while allowing for easier comparison between other <see cref="Resolution"/>s.
/// </summary>
public struct Resolution : IComparable < Resolution >
2018-11-30 02:41:06 +00:00
{
2019-01-14 07:26:46 +00:00
/// <summary>
/// Dimensions of resolution.
/// </summary>
2018-11-30 02:41:06 +00:00
public int Width , Height ;
2019-01-14 07:26:46 +00:00
/// <summary>
/// Constructs resolution given the dimensions.
/// </summary>
/// <param name="width">Width of resolution.</param>
/// <param name="height">Height of resolution.</param>
2018-11-30 02:41:06 +00:00
public Resolution ( int width , int height )
{
Width = width ;
Height = height ;
}
2019-01-14 07:26:46 +00:00
/// <summary>
/// Compares area of this resolution to another.
/// </summary>
/// <param name="other">The other resolution to compare to.</param>
/// <returns>A value less than 0 for this being the smaller resolution, 0 for the two being the same in area, and larger for this being the larger in area.</returns>
2018-11-30 02:41:06 +00:00
public int CompareTo ( Resolution other )
{
return Area ( ) - other . Area ( ) ;
}
2019-01-14 07:26:46 +00:00
/// <summary>
/// Gets a string representation of this resolution.
/// </summary>
/// <returns>"WidthxHeight"</returns>
2018-11-30 02:41:06 +00:00
public override string ToString ( )
{
return Width + "x" + Height ;
}
2019-01-14 07:26:46 +00:00
/// <summary>
/// Calculates area of resolution.
/// </summary>
/// <returns>Area of resolution.</returns>
2018-11-30 02:41:06 +00:00
public int Area ( )
{
return Width * Height ;
}
}
}