another data view
This commit is contained in:
parent
85ae3e302c
commit
91ab911f9c
1 changed files with 44 additions and 23 deletions
23
TanksServer/ServicePointDisplay/FixedSizeBitGridView.cs
Normal file
23
TanksServer/ServicePointDisplay/FixedSizeBitGridView.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System.Diagnostics;
|
||||
|
||||
namespace TanksServer.ServicePointDisplay;
|
||||
|
||||
internal sealed class FixedSizeBitGridView(Memory<byte> data, int columns, int rows)
|
||||
{
|
||||
private readonly FixedSizeBitRowView _bits = new(data);
|
||||
|
||||
public bool this[PixelPosition position]
|
||||
{
|
||||
get => _bits[ToPixelIndex(position)];
|
||||
set => _bits[ToPixelIndex(position)] = value;
|
||||
}
|
||||
|
||||
private int ToPixelIndex(PixelPosition position)
|
||||
{
|
||||
Debug.Assert(position.X < columns);
|
||||
Debug.Assert(position.Y < rows);
|
||||
var index = position.Y * columns + position.X;
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(index, nameof(position));
|
||||
return index;
|
||||
}
|
||||
}
|
||||
Reference in a new issue