From 205a5e4cbdf5fb348e94f6c89461831a83f9aec7 Mon Sep 17 00:00:00 2001 From: Dmitry Bubelnik Date: Fri, 25 Oct 2024 11:39:58 +0300 Subject: [PATCH] implement boolean logic in bitmap2 --- spatial/Bitmap2.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spatial/Bitmap2.cs b/spatial/Bitmap2.cs index 8226c24e..c62c4422 100644 --- a/spatial/Bitmap2.cs +++ b/spatial/Bitmap2.cs @@ -68,6 +68,8 @@ public Bitmap2(BitArray bits, Vector2i dimensions) public AxisAlignedBox2i GridBounds => new AxisAlignedBox2i(Vector2i.Zero, Dimensions); + public BitArray Bits => (BitArray)_bits.Clone(); + public bool this[int i] { get { return _bits[i]; } @@ -178,6 +180,12 @@ public IEnumerable NonZeros() public Bitmap2 Not() => new Bitmap2(((BitArray)_bits.Clone()).Not(), _dimensions); + public Bitmap2 Or(Bitmap2 other) => new Bitmap2(((BitArray)_bits.Clone()).Or(other._bits), _dimensions); + + public Bitmap2 Xor(Bitmap2 other) => new Bitmap2(((BitArray)_bits.Clone()).Xor(other._bits), _dimensions); + + public Bitmap2 And(Bitmap2 other) => new Bitmap2(((BitArray)_bits.Clone()).And(other._bits), _dimensions); + public bool Equals(Bitmap2 other) { if (ReferenceEquals(null, other)) return false;