1
mirror of https://gitlab.com/jessieh/qrprinter.git synced 2024-09-19 14:01:46 +00:00
qrprinter/README.md

72 lines
1.6 KiB
Markdown
Raw Normal View History

2021-10-07 06:20:40 +00:00
# <img src="../../raw/assets/icon.png" width=75> qrprinter
2021-10-07 05:55:46 +00:00
A wrapper for `libqrencode` that provides an easy way of encoding and printing strings as QR codes from Lua.
Written in [Fennel](https://fennel-lang.org).
## Installation
2021-10-07 19:59:18 +00:00
Install dependencies:
```bash
2021-10-07 20:18:33 +00:00
# Debian/Ubuntu:
2021-10-07 19:59:18 +00:00
apt install libqrencode-dev
# Alpine:
apk add gcompat libqrencode-dev
```
2021-10-07 05:55:46 +00:00
Install with [luarocks](https://luarocks.org):
```bash
luarocks install qrprinter
```
2021-10-07 08:36:27 +00:00
For a list of available versions, see the [luarocks module page](https://luarocks.org/modules/jessieh/qrprinter).
2021-10-07 05:55:46 +00:00
## Example Usage
2021-10-07 06:20:40 +00:00
<img src="../../raw/assets/demo.png" width=500>
2021-10-07 05:55:46 +00:00
## Documentation
### Encoding
#### qrprinter.encode_string
```
qrprinter.encode_string( string )
```
2021-10-07 08:36:27 +00:00
Encodes `string` into a table representing a QR code.\
Returns a two-dimensional sequential table of true/false values representing black/white QR modules.
2021-10-07 05:55:46 +00:00
### Printing
All print functions accept an optional table `options` that may contain two keys:
* `invert`: If non-nil, the output colors will be inverted
* `padding`: Number of blanks cells to print around the QR code (default 2)
#### qrprinter.print_qr
```
qrprinter.print_qr( qr, [options] )
```
Print `qr` to `stdout` using ANSI escape sequences.\
Alias of `qrprinter.print_qr_ansi`.
#### qrprinter.print_qr_ascii
```
qrprinter.print_qr_ascii( qr, [options] )
```
Print `qr` to `stdout` using ASCII characters.
#### qrprinter.print_qr_ansi
```
qrprinter.print_qr_ansi( qr, [options] )
```
Print `qr` to `stdout` using ANSI escape sequences.
#### qrprinter.print_qr_utf8
```
qrprinter.print_qr_utf8( qr, [options] )
```
Print `qr` to `stdout` using UTF8 block elements.