Create new Extents type and add debugger display attributes.
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Dashboard
|
||||
{
|
||||
[DebuggerDisplay("\\{{Min}; {Max}\\}")]
|
||||
public readonly record struct Box2d(Vector2 Min, Vector2 Max)
|
||||
{
|
||||
public float Left => Min.X;
|
||||
public float Right => Max.X;
|
||||
public float Top => Min.Y;
|
||||
public float Right => Max.X;
|
||||
public float Bottom => Max.Y;
|
||||
|
||||
public Vector2 Size => Max - Min;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using System.Drawing;
|
||||
using System.Diagnostics;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Dashboard
|
||||
{
|
||||
[DebuggerDisplay("\\{{Min}; {Max}\\}")]
|
||||
public readonly record struct Box3d(Vector3 Min, Vector3 Max)
|
||||
{
|
||||
public float Left => Min.X;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Diagnostics;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Dashboard
|
||||
{
|
||||
[DebuggerDisplay("{Value}")]
|
||||
public readonly record struct Extents(Vector4 Value)
|
||||
{
|
||||
public float Left => Value.X;
|
||||
public float Top => Value.Y;
|
||||
public float Right => Value.Z;
|
||||
public float Bottom => Value.W;
|
||||
|
||||
public float ExtentWidth => Left + Right;
|
||||
|
||||
public float ExtentHeight => Top + Bottom;
|
||||
|
||||
public Vector2 ExtentSize => new(ExtentWidth, ExtentHeight);
|
||||
|
||||
public Extents(float left, float top, float right, float bottom)
|
||||
: this(new Vector4(left, top, right, bottom))
|
||||
{
|
||||
}
|
||||
|
||||
public Extents(float value) : this(new Vector4(value))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user