Make bounds a Box3d.
This commit is contained in:
parent
c706e16db1
commit
34720970ff
@ -6,4 +6,8 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Dashboard\Dashboard.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
|
||||||
@ -64,8 +65,11 @@ namespace Dashboard.Drawing
|
|||||||
|
|
||||||
public static void Point(this DrawQueue queue, Vector3 position, float size, IBrush brush)
|
public static void Point(this DrawQueue queue, Vector3 position, float size, IBrush brush)
|
||||||
{
|
{
|
||||||
|
Vector3 radius = new Vector3(size / 2f);
|
||||||
|
Box3d bounds = new Box3d(position - radius, position + radius);
|
||||||
|
|
||||||
var controller = queue.GetController(DbBaseCommands.Instance);
|
var controller = queue.GetController(DbBaseCommands.Instance);
|
||||||
controller.EnsureSize(position);
|
controller.EnsureBounds(bounds);
|
||||||
controller.Write(DbBaseCommands.Instance.DrawPoint, new PointCommandArgs(position, size, brush));
|
controller.Write(DbBaseCommands.Instance.DrawPoint, new PointCommandArgs(position, size, brush));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Numerics;
|
|
||||||
|
|
||||||
namespace Dashboard.Drawing
|
namespace Dashboard.Drawing
|
||||||
{
|
{
|
||||||
@ -15,9 +15,9 @@ namespace Dashboard.Drawing
|
|||||||
private readonly MemoryStream _commandStream = new MemoryStream();
|
private readonly MemoryStream _commandStream = new MemoryStream();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Size of the image in points.
|
/// The absolute boundary of all graphics objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector3 Size { get; private set; } = Vector3.Zero;
|
public Box3d Bounds { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The extensions required to draw the image.
|
/// The extensions required to draw the image.
|
||||||
@ -163,19 +163,9 @@ namespace Dashboard.Drawing
|
|||||||
|
|
||||||
private class DrawController(DrawQueue Queue) : IDrawController
|
private class DrawController(DrawQueue Queue) : IDrawController
|
||||||
{
|
{
|
||||||
public void EnsureSize(Vector3 size)
|
public void EnsureBounds(Box3d bounds)
|
||||||
{
|
{
|
||||||
Queue.Size = Vector3.Max(Queue.Size, size);
|
Queue.Bounds = Box3d.Union(Queue.Bounds, bounds);
|
||||||
}
|
|
||||||
|
|
||||||
public int Require(IDrawExtension extension)
|
|
||||||
{
|
|
||||||
return Queue.RequireExtension(extension);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetResourceIndex(IDrawResource resource)
|
|
||||||
{
|
|
||||||
return Queue._resources.Intern(resource);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(IDrawCommand command)
|
public void Write(IDrawCommand command)
|
||||||
@ -237,8 +227,8 @@ namespace Dashboard.Drawing
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ensures that the canvas is at least a certain size.
|
/// Ensures that the canvas is at least a certain size.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="size">The minimum size.</param>
|
/// <param name="bounds">The bounding box.</param>
|
||||||
void EnsureSize(Vector3 size);
|
void EnsureBounds(Box3d bounds);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Write into the command stream.
|
/// Write into the command stream.
|
||||||
|
Loading…
Reference in New Issue
Block a user