wip new display module
This commit is contained in:
parent
7e767d6dcb
commit
38463ac109
1 changed files with 321 additions and 1 deletions
25
DisplayCommands/ByteGrid.cs
Normal file
25
DisplayCommands/ByteGrid.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System.Diagnostics;
|
||||
|
||||
namespace DisplayCommands;
|
||||
|
||||
public class ByteGrid(ushort width, ushort height)
|
||||
{
|
||||
public ushort Height { get; } = height;
|
||||
|
||||
public ushort Width { get; } = width;
|
||||
|
||||
internal Memory<byte> Data { get; } = new byte[width * height].AsMemory();
|
||||
|
||||
public byte this[ushort x, ushort y]
|
||||
{
|
||||
get => Data.Span[ GetIndex(x, y)];
|
||||
set => Data.Span[GetIndex(x, y)] = value;
|
||||
}
|
||||
|
||||
private int GetIndex(ushort x, ushort y)
|
||||
{
|
||||
Debug.Assert(x < Width);
|
||||
Debug.Assert(y < Height);
|
||||
return x + y * Width;
|
||||
}
|
||||
}
|
||||
Reference in a new issue