pablohirafuji/elm-qrcode/2.0.0

NOTE: this package is not compatible with Elm 0.19.1

QRCode

QR Code encoding and rendering.

type QRCode

QRCode type.

Encoding

encode : String -> Result Error QRCode

Transform a string into a result Error or a QRCode using ECLevel.Q (25% of codewords can be restored).

encodeWithECLevel : String -> ECLevel -> Result Error QRCode

Transform a string with a given EClevel into a result Error or a QRCode.

Rendering

toSvg : QRCode -> Html msg

Transform a QRCode into a svg element.

qrCodeView : String -> Html msg
qrCodeView message =
    QRCode.encode message
        |> Result.map QRCode.toSvg
        |> Result.withDefault
            (Html.text "Error while encoding to QRCode.")

Tip: You can determine the size of the generated svg setting width and height styles.

toString : QRCode -> String

Transform a QRCode into a string.

"Hello World!"
    |> QRCode.encode
    |> Result.map QRCode.toString
    |> Result.withDefault ""

Returns:

■■■■■■■ ■■■■  ■■■■■■■
■     ■ ■■■■  ■     ■
■ ■■■ ■ ■■■■■ ■ ■■■ ■
■ ■■■ ■ ■   ■ ■ ■■■ ■
■ ■■■ ■ ■■■■  ■ ■■■ ■
■     ■    ■  ■     ■
■■■■■■■ ■ ■ ■ ■■■■■■■
        ■ ■■         
 ■■ ■ ■■  ■   ■ ■■■■■
■■ ■■■   ■■■■ ■■■  ■■
 ■ ■■ ■■ ■■■■■ ■■■■■■
 ■■      ■■■■   ■  ■ 
■  ■ ■■■  ■■■■ ■■    
        ■■ ■■■    ■■ 
■■■■■■■ ■ ■    ■■ ■■■
■     ■  ■  ■  ■    ■
■ ■■■ ■ ■■■     ■    
■ ■■■ ■   ■■  ■■■ ■■ 
■ ■■■ ■ ■ ■ ■ ■ ■ ■ ■
■     ■ ■  ■    ■  ■ 
■■■■■■■   ■■■  ■   ■■