We got CSS at home
This commit is contained in:
@@ -20,4 +20,62 @@ public record Rect(float Width = 0.0f, float Height = 0.0f)
|
||||
public static bool operator <(Rect left, Rect right) => left.CompareTo(right) < 0;
|
||||
public static bool operator >=(Rect left, Rect right) => left.CompareTo(right) >= 0;
|
||||
public static bool operator <=(Rect left, Rect right) => left.CompareTo(right) <= 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the size offsets applied around a rectangle.
|
||||
/// </summary>
|
||||
public struct Size : IEquatable<Size>
|
||||
{
|
||||
public float Left;
|
||||
public float Right;
|
||||
public float Top;
|
||||
public float Bottom;
|
||||
|
||||
public Size(float uniform)
|
||||
{
|
||||
Left = Right = Top = Bottom = uniform;
|
||||
}
|
||||
|
||||
public Size(float horizontal, float vertical)
|
||||
{
|
||||
Left = Right = horizontal;
|
||||
Top = Bottom = vertical;
|
||||
}
|
||||
|
||||
public Size(float left, float right, float top, float bottom)
|
||||
{
|
||||
Left = left;
|
||||
Right = right;
|
||||
Top = top;
|
||||
Bottom = bottom;
|
||||
}
|
||||
|
||||
public static Size Zero => new Size(0);
|
||||
|
||||
public static Rect operator +(Size margin, Rect rect) =>
|
||||
new Rect(rect.Width + margin.Left + margin.Right,
|
||||
rect.Height + margin.Top + margin.Bottom);
|
||||
|
||||
public static Rect operator +(Rect rect, Size margin) =>
|
||||
margin + rect;
|
||||
|
||||
|
||||
public static bool operator ==(Size a, Size b) =>
|
||||
a.Equals(b);
|
||||
|
||||
public static bool operator !=(Size a, Size b) =>
|
||||
!a.Equals(b);
|
||||
|
||||
public bool Equals(Size other) =>
|
||||
Left == other.Left &&
|
||||
Right == other.Right &&
|
||||
Top == other.Top &&
|
||||
Bottom == other.Bottom;
|
||||
|
||||
public override bool Equals(object? obj) =>
|
||||
obj is Size other && Equals(other);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
HashCode.Combine(Left, Right, Top, Bottom);
|
||||
}
|
||||
Reference in New Issue
Block a user