Create new Extents type and add debugger display attributes.

This commit is contained in:
2026-09-07 21:50:43 +03:00
parent 362165f911
commit 4f7edd42d0
3 changed files with 34 additions and 3 deletions
+3 -2
View File
@@ -1,14 +1,15 @@
using System.ComponentModel.DataAnnotations; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Numerics; using System.Numerics;
namespace Dashboard namespace Dashboard
{ {
[DebuggerDisplay("\\{{Min}; {Max}\\}")]
public readonly record struct Box2d(Vector2 Min, Vector2 Max) public readonly record struct Box2d(Vector2 Min, Vector2 Max)
{ {
public float Left => Min.X; public float Left => Min.X;
public float Right => Max.X;
public float Top => Min.Y; public float Top => Min.Y;
public float Right => Max.X;
public float Bottom => Max.Y; public float Bottom => Max.Y;
public Vector2 Size => Max - Min; public Vector2 Size => Max - Min;
+2 -1
View File
@@ -1,8 +1,9 @@
using System.Drawing; using System.Diagnostics;
using System.Numerics; using System.Numerics;
namespace Dashboard namespace Dashboard
{ {
[DebuggerDisplay("\\{{Min}; {Max}\\}")]
public readonly record struct Box3d(Vector3 Min, Vector3 Max) public readonly record struct Box3d(Vector3 Min, Vector3 Max)
{ {
public float Left => Min.X; public float Left => Min.X;
+29
View File
@@ -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))
{
}
}
}