QRCode

A QRCode (Quick Response Code) is a matrix of nominally square modules arranged in an overall square pattern. It can be used to encode a variety of data formats: numeric, alphanumeric, byte and kanji. This implementation is based on the international standard for QR Code 2005. github

There are two ways to generate a QRCode: (1) Sending the asQRCode / asMicroQRCode message to an object, usually a String or Integer (e.g., 'http://smalltalkhub.com' asQRCode). asQRCode will produce a standard Model 2 QR Code. asMicroQRCode will produce a Micro QR Code. There are many readers that do not accept Micro QR, so it is safest to just use asQRCode. (2) To specify something different (different error correction level, ECI encoding) than the default, use the "QRCode creation" protocol class methods in QRCodeEncoder. QR Code allows you to specify four levels of error correction: (L) Recovery of 7% of the symbol codewords (M) Recovery of 15% of the symbol codewords (Q) Recovery of 25% of the symbol codewords (H) Recovery of 30% of the symbol codewords The higher the level of error correction, the larger the symbol needs to be. To minimize symbol extent, $L is is used as the default error correction. To further minimize symbol extent, keeping to alphanumeric mode can be useful but requires that all letters are uppercase. As URLs (the most common use for QR Code) are largely case insensitive, alphanumeric mode is probably sufficient. While error correction is a core feature of the QRCode specification, many readers don't utilize it. After initialization, this class serves as a wrapper for the QRCode, allowing access to its string, encoding, version, errorCorrection, and eci; these cannot be changed after creation. Most importantly, you can access its form. For example, do the following code: ('HTTP://SMALLTALKHUB.COM' asQRCode form magnifyBy: 10) asMorph openInWorld. | instance | instance := 'http://smalltalkhub.com' asQRCode. instance backgroundColor: Color green. instance foregroundColor: Color yellow. (instance formWithQuietZone magnifyBy: 10) asMorph openInWorld. This class also implements two of the features of QR Code 2005: reversing and mirroring. You can reverse the symbol (i.e., exchange background and foreground colors) by sending the reverse message to the QRCode. You can mirror the symbol (i.e., flip the symbol left to right) by sending the mirror message to the QRCode; it is not clear why you would want to do that, but it is in the specifications. While black and white are specified as the nominal foreground and background colors respectively, you can change them to arbitrary colors (as above). Be cautious using these features; many readers do not support them.