// Copyright (c) 2017 Eric Mellino
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
using System.Collections.Generic;
using System.Text;
namespace Vulkan
{
///
/// Structure specifying a two-dimensional subregion.
///
public partial struct VkRect2D : IEquatable
{
///
/// An with all of its components set to zero.
///
public static readonly VkRect2D Zero = new VkRect2D(VkOffset2D.Zero, VkExtent2D.Zero);
///
/// Initializes a new instance of the structure.
///
/// The offset component of the rectangle.
/// The extent component of the rectangle.
public VkRect2D(VkOffset2D offset, VkExtent2D extent)
{
this.offset = offset;
this.extent = extent;
}
///
/// Initializes a new instance of the structure.
///
/// The extent component of the rectangle.
public VkRect2D(VkExtent2D extent)
{
this.offset = default(VkOffset2D);
this.extent = extent;
}
///
/// Initializes a new instance of the structure.
///
/// The X component of the offset.
/// The Y component of the offset.
/// The width component of the extent.
/// The height component of the extent.
public VkRect2D(int x, int y, uint width, uint height)
{
this.offset = new VkOffset2D(x, y);
this.extent = new VkExtent2D(width, height);
}
///
/// Initializes a new instance of the structure.
///
/// The X component of the offset.
/// The Y component of the offset.
/// The width component of the extent.
/// The height component of the extent.
public VkRect2D(int x, int y, int width, int height)
{
this.offset = new VkOffset2D(x, y);
this.extent = new VkExtent2D(width, height);
}
///
/// Initializes a new instance of the structure.
///
/// The width component of the extent.
/// The height component of the extent.
public VkRect2D(uint width, uint height)
{
this.offset = default(VkOffset2D);
this.extent = new VkExtent2D(width, height);
}
///
/// Determines whether the specified is equal to this instance.
///
/// The to compare with this instance.
///
/// true if the specified is equal to this instance; otherwise, false.
///
public bool Equals(ref VkRect2D other)
{
return other.offset.Equals(ref offset) && other.extent.Equals(ref extent);
}
///
/// Determines whether the specified is equal to this instance.
///
/// The to compare with this instance.
///
/// true if the specified is equal to this instance; otherwise, false.
///
public bool Equals(VkRect2D other)
{
return Equals(ref other);
}
///
/// Determines whether the specified is equal to this instance.
///
/// The to compare with this instance.
///
/// true if the specified is equal to this instance; otherwise, false.
///
public override bool Equals(object obj)
{
return obj is VkRect2D && Equals((VkRect2D)obj);
}
///
/// Returns the hash code for this instance.
///
/// The hash code.
public override int GetHashCode()
{
unchecked
{
int hashCode = extent.GetHashCode();
hashCode = (hashCode * 397) ^ offset.GetHashCode();
return hashCode;
}
}
///
/// Returns a boolean indicating whether the two given rectangles are equal.
///
/// The first rectangle to compare.
/// The second rectangle to compare.
/// true if the rectangles are equal; false otherwise.
public static bool operator ==(VkRect2D left, VkRect2D right) => left.Equals(right);
///
/// Returns a boolean indicating whether the two given rectangles are not equal.
///
/// The first rectangle to compare.
/// The second rectangle to compare.
///
/// true if the rectangles are not equal; false if they are equal.
///
public static bool operator !=(VkRect2D left, VkRect2D right) => !left.Equals(right);
}
}