Struct QrRectangle
- Namespace
- Net.Codecrete.QrCodeGenerator
- Assembly
- QrCodeGenerator.dll
A rectangular block of dark modules within a QR code.
The coordinates use the same system as GetModule(int, int): the top-left module is at (x=0, y=0), x extends to the right and y extends downwards. Each unit is one module (QR code pixel); no border is included.
Instances are produced by ToRectangles(), which merges adjacent dark modules into larger rectangles to reduce the number of shapes that need to be drawn.
public readonly struct QrRectangle : IEquatable<QrRectangle>
- Implements
- Inherited Members
Constructors
QrRectangle(int, int, int, int)
Initializes a new rectangle with the specified position and size.
public QrRectangle(int x, int y, int width, int height)
Parameters
xintThe x-coordinate of the top-left module.
yintThe y-coordinate of the top-left module.
widthintThe width, in modules.
heightintThe height, in modules.
Properties
Height
The height of this rectangle.
public int Height { get; }
Property Value
- int
The height, in modules.
Width
The width of this rectangle.
public int Width { get; }
Property Value
- int
The width, in modules.
X
The x-coordinate of the top-left module of this rectangle.
public int X { get; }
Property Value
- int
The x-coordinate, in modules.
Y
The y-coordinate of the top-left module of this rectangle.
public int Y { get; }
Property Value
- int
The y-coordinate, in modules.
Methods
Deconstruct(out int, out int, out int, out int)
Deconstructs this rectangle into its position and size.
public void Deconstruct(out int x, out int y, out int width, out int height)
Parameters
xintReceives the x-coordinate of the top-left module.
yintReceives the y-coordinate of the top-left module.
widthintReceives the width, in modules.
heightintReceives the height, in modules.
Equals(QrRectangle)
Determines whether this rectangle is equal to the specified rectangle.
public bool Equals(QrRectangle other)
Parameters
otherQrRectangleThe rectangle to compare with.
Returns
- bool
trueif both rectangles have the same position and size.
Equals(object)
Determines whether this rectangle is equal to the specified object.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with.
Returns
- bool
trueifobjis a QrRectangle with the same position and size.
GetHashCode()
Returns the hash code for this rectangle.
public override int GetHashCode()
Returns
- int
The hash code.
ToString()
Returns a string representation of this rectangle.
public override string ToString()
Returns
- string
A string with the position and size.
Operators
operator ==(QrRectangle, QrRectangle)
Determines whether two rectangles are equal.
public static bool operator ==(QrRectangle left, QrRectangle right)
Parameters
leftQrRectangleThe first rectangle.
rightQrRectangleThe second rectangle.
Returns
- bool
trueif both rectangles have the same position and size.
operator !=(QrRectangle, QrRectangle)
Determines whether two rectangles are not equal.
public static bool operator !=(QrRectangle left, QrRectangle right)
Parameters
leftQrRectangleThe first rectangle.
rightQrRectangleThe second rectangle.
Returns
- bool
trueif the rectangles differ in position or size.