| Copyright | (c) 2022 Manuel Spagnolo |
|---|---|
| License | MIT |
| Maintainer | Manuel Spagnolo <spagnolo.manu@gmail.com> |
| Safe Haskell | None |
| Language | Haskell2010 |
Kewar
Description
Generate a QR code from a given input string.
The output of the entry point generate is an array representing the drawable representation of the QR code,
meaning a data structure that can be mapped - for instance - to terminal output or images.
The module includes a CLI utility which prints the QR code directly in the terminal as an example.
You can install it via
cabal install exe:kewar
And use it like
kewar "Hello World"
██████████████ ██ ██ ████████ ██████████████
██ ██ ██████ ████████ ██ ██
██ ██████ ██ ██████ ██ ██ ██████ ██
██ ██████ ██ ██ ████ ██ ██████ ██
██ ██████ ██ ████ ██ ████ ██ ██████ ██
██ ██ ██ ██ ██ ██
██████████████ ██ ██ ██ ██ ██ ██████████████
██ ██ ██
██████████████ ██ ████ ██
██████ ██ ██████ ██████ ██ ██
██████ ██ ██ ████ ██████████ ████ ████
██ ██████████ ██ ██ ██ ████
██ ██ ██████ ██ ████ ████████████████
██ ████████ ████████ ████ ██ ██
██ ██ ██ ██ ██ ██████████ ████
██ ██ ██ ██ ████ ██ ██ ██ ██████ ██
██ ██ ██ ████ ██ ██████████████
██ ██ ██ ██
██████████████ ██████ ████ ████ ██ ██ ██████
██ ██ ██ ██ ████████ ████ ██
██ ██████ ██ ██ ████ ████████████████
██ ██████ ██ ████ ██ ██ ████ ██
██ ██████ ██ ██ ██ ████ ████ ██ ██
██ ██ ██ ██████ ██ ██ ████ ██
██████████████ ████ ████ ██ ██ ████
Documentation
generate :: String -> CorrectionLevel -> Either Exception Grid Source #
Entry point of the library. Attempts generating a QR Code Grid from a given input string.
data CorrectionLevel Source #
Correction Level allows reading QR codes in case they get damaged or unreadable.
Constructors
| L | allows up to 7% data recovery |
| M | allows up to 15% data recovery |
| Q | allows up to 25% data recovery |
| H | allows up to 30% data recovery |
Instances
| Eq CorrectionLevel Source # | |
Defined in Kewar.Types Methods (==) :: CorrectionLevel -> CorrectionLevel -> Bool # (/=) :: CorrectionLevel -> CorrectionLevel -> Bool # | |
| Show CorrectionLevel Source # | |
Defined in Kewar.Types Methods showsPrec :: Int -> CorrectionLevel -> ShowS # show :: CorrectionLevel -> String # showList :: [CorrectionLevel] -> ShowS # | |
type Grid = Array Position Module Source #
Array holding the drawable representation of the QR code. It includes encoded data, functional patterns, format, and version bits.
cols :: Grid -> [[(Position, Module)]] Source #
Returns a list of columns for a given grid. Useful for drawing.
rows :: Grid -> [[(Position, Module)]] Source #
Returns a list of rows for a given grid. Useful for drawing.
A module represent a single unit composing a QR code. We're not using the word pixel as they usually span more than a pixel.