Table of Contents

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

x int

The x-coordinate of the top-left module.

y int

The y-coordinate of the top-left module.

width int

The width, in modules.

height int

The 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

x int

Receives the x-coordinate of the top-left module.

y int

Receives the y-coordinate of the top-left module.

width int

Receives the width, in modules.

height int

Receives the height, in modules.

Equals(QrRectangle)

Determines whether this rectangle is equal to the specified rectangle.

public bool Equals(QrRectangle other)

Parameters

other QrRectangle

The rectangle to compare with.

Returns

bool

true if 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

obj object

The object to compare with.

Returns

bool

true if obj is 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

left QrRectangle

The first rectangle.

right QrRectangle

The second rectangle.

Returns

bool

true if 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

left QrRectangle

The first rectangle.

right QrRectangle

The second rectangle.

Returns

bool

true if the rectangles differ in position or size.

See Also