kewar-0.1.1.1: CLI and library to generate QR codes.
Copyright(c) 2022 Manuel Spagnolo
LicenseMIT
MaintainerManuel Spagnolo <spagnolo.manu@gmail.com>
Safe HaskellNone
LanguageHaskell2010

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"
██████████████  ██  ██  ████████    ██████████████
██          ██    ██████  ████████  ██          ██
██  ██████  ██        ██████  ██    ██  ██████  ██
██  ██████  ██      ██      ████    ██  ██████  ██
██  ██████  ██  ████  ██      ████  ██  ██████  ██
██          ██  ██    ██            ██          ██
██████████████  ██  ██  ██  ██  ██  ██████████████
                        ██  ██  ██                
  ██████████████                ██    ████      ██
      ██████  ██  ██████  ██████      ██    ██    
    ██████  ██  ██  ████  ██████████    ████  ████
      ██      ██████████  ██  ██    ██        ████
██  ██    ██████      ██    ████  ████████████████
██  ████████      ████████    ████    ██    ██    
██          ██  ██      ██  ██    ██████████  ████
██  ██    ██  ██  ████  ██  ██  ██  ██████      ██
██      ██  ██  ████  ██        ██████████████    
                                ██      ██  ██  ██
██████████████  ██████  ████  ████  ██  ██  ██████
██          ██  ██  ██    ████████      ████  ██  
██  ██████  ██  ██  ████      ████████████████    
██  ██████  ██  ████        ██      ██  ████    ██
██  ██████  ██  ██    ██    ████    ████  ██    ██
██          ██  ██  ██████    ██  ██  ████      ██
██████████████    ████  ████    ██    ██      ████
Synopsis

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

Instances details
Eq CorrectionLevel Source # 
Instance details

Defined in Kewar.Types

Show CorrectionLevel Source # 
Instance details

Defined in Kewar.Types

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.

data Module Source #

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.

Constructors

Black

Dark module

White

Light module

Instances

Instances details
Eq Module Source # 
Instance details

Defined in Kewar.Layout.Types

Methods

(==) :: Module -> Module -> Bool #

(/=) :: Module -> Module -> Bool #

type Position = (Int, Int) Source #

Position of a module in a given grid. It's in the form (row index, column index).