# \[ANN\] QRCode.jl: Create QR Code within Julia

**URL:** <https://discourse.julialang.org/t/ann-qrcode-jl-create-qr-code-within-julia/26923>\
**Category:** Community\
**Tags:** package, announcement\
**Created:** [July 29, 2019, 3:46am UTC](https://discourse.julialang.org/t/ann-qrcode-jl-create-qr-code-within-julia/26923 "2019-07-29T03:46:20Z")\
**Posts on this page:** 1\
**Showing post:** 25

<div class="post-metadata">

**Author:** ![c42f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/c42f/32/52842_2.png) [@c42f](https://discourse.julialang.org/u/c42f)\
**Post date:** [July 30, 2019, 4:41am UTC](https://discourse.julialang.org/t/ann-qrcode-jl-create-qr-code-within-julia/26923/25 "2019-07-30T04:41:23Z")

</div>

That’s the idea - wrap it in a struct and override `Base.show`. Though there’s an attractive simplicity in just returning a `BitArray` 🙂

If you do want to go with a wrapper type you might use `QRCode` though you’d have to rename your package to QRCodes.jl (module name pluralization is an ecosystem convention to deal with this, eg `Colors.Color`, `Dates.Date`, `Rotations.Rotation` etc etc)

If you made a wrapper, what interface would you want it to conform to other than having a nice default `show` method? Eg, is it a graphical object, an `AbstractMatrix` or something else entirely? Perhaps best to keep it simple:

```julia
struct QRCode
    data::BitMatrix
    # Add more things here, eg the code version,
    # original source data string, etc
end

function Base.show(io::IO, code::QRCode)
    # You can include the original text in a header line too if it's part of QRCode
    # Minimal ANSI color text representation:
    for i=1:size(code.data,1)
        println(io, join([code.data[i,j] ? "\e[30m██" : "\e[97m██" for j=1:size(code.data,2)]))
    end
end

# possibly also `show(io::IO, ::MIME"text/html", qrc::QRCode)` for IJulia and the like?

```

---

_[View the full topic](https://discourse.julialang.org/t/ann-qrcode-jl-create-qr-code-within-julia/26923)._
