BinaryImage Structure

Represents a 5x5 binary image. The image is stored as an integer, where each bit represents a cell in the image. The top left corner is viewed the least significant bit. We go down row by row from left to right.

Example

 
#####         11111
##.##         11011  
##..#  ---->  11001  ---->  0b10011_10001_10011_11011_11111
#...#         10001    
##..#         11001

Definition

Namespace: ProjectLCore.GamePieces
Assembly: ProjectLCore (in ProjectLCore.dll) Version: 1.0.0+d0f5e2a7a5f4bb0431970f279d2f79d24b15d256
C#
public readonly struct BinaryImage : IEquatable<BinaryImage>
Inheritance
Object    ValueType    BinaryImage
Implements
IEquatableBinaryImage

Constructors

BinaryImage(Boolean) Initializes a new instance of the BinaryImage struct using a bool[25]. The first 5 elements represent the first row (left to right), the next 5 elements represent the second row, and so on. Filled in cells are represented by and empty cells by .
BinaryImage(Int32) Initializes a new instance of the BinaryImage struct using an encoding of the image into an integer. The encoding should be as specified in the BinaryImage class documentation.

Properties

EmptyImage The image which has all cells empty.
FullImage The image which has all cells filled in.
ItemInt32 Gets the cell at the specified index: image[i,j] is equivalent to image[i * 5 + j].
ItemInt32, Int32 Gets the cell at the specified position.

Methods

CountEmptyCells Counts the empty cells.
CountFilledCells Counts the filled cells.
Equals(BinaryImage) Indicates whether the current BinaryImage is equal to another BinaryImage. Two images are equal if all of their cells are the same.
Equals(Object) Determines whether the specified object is equal to the current BinaryImage.
(Overrides ValueTypeEquals(Object))
FlipHorizontally Flips the image about the Y axis.
FlipVertically Flips the image about the X axis.
GetHashCode Returns a hash code for this instance.
(Overrides ValueTypeGetHashCode)
MoveDown Attempts to move the cells of the image down by one cell. If there is a filled cell in the bottom row, no transformation is done.
MoveImageToTopLeftCorner Moves the filled in cells to the top left corner of the image.
MoveLeft Attempts to move the cells of the image left by one cell. If there is a filled cell in the left column, no transformation is done.
MoveRight Attempts to move the cells of the image right by one cell. If there is a filled cell in the right column, no transformation is done.
MoveUp Attempts to move the cells of the image up by one cell. If there is a filled cell in the top row, no transformation is done.
RotateLeft Rotates the image 90 degrees to the left.
RotateRight Rotates the image 90 degrees to the right.
ToString Converts to string. '#' represents filled cell, '.' represents empty cell.
(Overrides ValueTypeToString)

Operators

BitwiseAnd(BinaryImage, BinaryImage) Implements the operator &. The intersection of two images is the image where a cell is filled in if and only if both images have the cell filled in.
BitwiseOr(BinaryImage, BinaryImage) Implements the operator |. The union of two images is the image where a cell is filled in if and only if at least one of the images have the cell filled in.
Equality(BinaryImage, BinaryImage) Implements the operator ==.
Inequality(BinaryImage, BinaryImage) Implements the operator !=.
OnesComplement(BinaryImage) Implements the operator ~. The complement of an image is the image where a cell is filled in if and only if the original image has the cell empty.

See Also