recrownedathenaeum/RecrownedAthenaeum/SpecialTypes/Resolution.cs

55 lines
1.6 KiB
C#
Raw Normal View History

using System;
2019-01-15 23:33:55 +00:00
namespace RecrownedAthenaeum.SpecialTypes
{
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>
{
2019-01-14 07:26:46 +00:00
/// <summary>
/// Dimensions of resolution.
/// </summary>
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>
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>
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>
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>
public int Area()
{
return Width * Height;
}
}
}