Skip to content

Commit

Permalink
implement boolean logic in bitmap2 (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryBubelnikSoftSmile authored Oct 25, 2024
1 parent 5e4885e commit e072fd6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion spatial/Bitmap2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public Bitmap2(BitArray bits, Vector2i dimensions)

public AxisAlignedBox2i GridBounds => new AxisAlignedBox2i(Vector2i.Zero, Dimensions);

public BitArray BitsCopy => (BitArray)_bits.Clone();

public bool this[int i]
{
get { return _bits[i]; }
Expand Down Expand Up @@ -176,7 +178,13 @@ public IEnumerable<Vector2i> NonZeros()
}
}

public Bitmap2 Not() => new Bitmap2(((BitArray)_bits.Clone()).Not(), _dimensions);
public Bitmap2 Not() => new Bitmap2(BitsCopy.Not(), _dimensions);

public Bitmap2 Or(Bitmap2 other) => new Bitmap2(BitsCopy.Or(other._bits), _dimensions);

public Bitmap2 Xor(Bitmap2 other) => new Bitmap2(BitsCopy.Xor(other._bits), _dimensions);

public Bitmap2 And(Bitmap2 other) => new Bitmap2(BitsCopy.And(other._bits), _dimensions);

public bool Equals(Bitmap2 other)
{
Expand Down

0 comments on commit e072fd6

Please sign in to comment.