Skip to content

QrCodeWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

Displays a QR code in the terminal using block characters.

csharp
public sealed record QrCodeWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<QrCodeWidget>

Inheritance

ObjectHex1bWidgetQrCodeWidget

Implements

Constructors

QrCodeWidget(string, int)

Displays a QR code in the terminal using block characters.

Parameters:

  • Data (String): The data to encode in the QR code (typically a URL).
  • QuietZone (Int32): The number of module widths to use as a border around the QR code. Defaults to 1. Set to 0 to disable the quiet zone.
csharp
public QrCodeWidget(string Data, int QuietZone = 1)

Properties

Data

The data to encode in the QR code (typically a URL).

Returns: String

csharp
public string Data { get; init; }

QuietZone

The number of module widths to use as a border around the QR code. Defaults to 1. Set to 0 to disable the quiet zone.

Returns: Int32

csharp
public int QuietZone { get; init; }

Remarks

QrCodeWidget renders QR codes using Unicode block characters (█) to create scannable QR codes in the terminal. The primary use case is encoding URLs.

The QR code is automatically sized based on the data length and error correction level. QR codes work best when displayed with a monospace font where character width equals height.

Error correction level is fixed at Q (Quartile - 25% recovery capability) which provides a good balance between data capacity and error recovery.

Examples

Basic URL QR code:

csharp
ctx.QrCode("https://github.com/mitchdenny/hex1b")

QR code without quiet zone:

csharp
ctx.QrCode("https://example.com", quietZone: 0)

Released under the MIT License.