using UnityEngine;
namespace NugetForUnity
{
///
/// Extension methods for manipulating Rect objects.
///
internal static class RectHelper
{
///
/// Expands the boundaries of the Rect by a specified value in all directions.
///
/// The rect to update.
/// The value to add.
/// The updated Rect.
public static Rect Expand(this Rect rect, float value)
{
rect.xMin -= value;
rect.xMax += value;
rect.yMin -= value;
rect.yMax += value;
return rect;
}
///
/// Expands the Rect horizontally by a specified value.
///
/// The rect to update.
/// The value to add.
/// The updated Rect.
public static Rect ExpandX(this Rect rect, float value)
{
rect.xMin -= value;
rect.xMax += value;
return rect;
}
///
/// Expands the Rect vertically by a specified value.
///
/// The rect to update.
/// The value to add.
/// The updated Rect.
public static Rect ExpandY(this Rect rect, float value)
{
rect.yMin -= value;
rect.yMax += value;
return rect;
}
///
/// Adds a specified value to the X-coordinate of the Rect.
///
/// The rect to update.
/// The value to add.
/// The updated Rect.
public static Rect AddX(this Rect rect, float value)
{
rect.x += value;
return rect;
}
///
/// Adds a specified value to the Y-coordinate of the Rect.
///
/// The rect to update.
/// The value to add.
/// The updated Rect.
public static Rect AddY(this Rect rect, float value)
{
rect.y += value;
return rect;
}
///
/// Sets the width of the Rect to a specified value.
///
/// The rect to update.
/// The value to set.
/// The updated Rect.
public static Rect SetWidth(this Rect rect, float value)
{
rect.width = value;
return rect;
}
///
/// Sets the height of the Rect to a specified value.
///
/// The rect to update.
/// The value to set.
/// The updated Rect.
public static Rect SetHeight(this Rect rect, float value)
{
rect.height = value;
return rect;
}
}
}