JuliaImages / QRCoders.jl

Creating QR Codes within Julia
https://juliaimages.org/QRCoders.jl/
MIT License
67 stars 11 forks source link

New structure type QRCode #35

Closed RexWzh closed 1 year ago

RexWzh commented 1 year ago

I use version, mode, eclevel, mask, message and width to represents a QR code.

mutable struct QRCode
    version::Int # version of the QR code
    mode::Mode # encoding mode
    eclevel::ErrCorrLevel
    mask::Int # mask pattern
    message::AbstractString # message to be encoded
    width::Int # width of the white border
end

In QRDecoders, it is QRInfo(immutable structure) that stores the information. However, the white-border(width) of a QR code is uncertain in general, so we might keep both QRInfo and QRCode.

codecov[bot] commented 1 year ago

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage :thumbsup:

Coverage data is based on head (7b60e86) compared to base (2db7512). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #35 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 6 6 Lines 376 435 +59 ========================================= + Hits 376 435 +59 ``` | [Impacted Files](https://codecov.io/gh/JuliaImages/QRCoders.jl/pull/35?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaImages) | Coverage Δ | | |---|---|---| | [src/QRCoders.jl](https://codecov.io/gh/JuliaImages/QRCoders.jl/pull/35/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaImages#diff-c3JjL1FSQ29kZXJzLmps) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaImages). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaImages)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

RexWzh commented 1 year ago

Demo

# codes with same settings
exportqrcode(["Hello world!", "Hello Julia!"], fps=2, eclevel=Low())

# equivalently
codes = QRCode.(["Hello world!", "Hello Julia!"], eclevel=Low())
exportqrcode(["Hello world!", "Hello Julia!"], fps=2)

# codes with different settings
using QRCoders: penalty
codes = [QRCode("Hello world!", mask = i) for i in 0:7]
qrcode.(codes) .|> penalty
# [425, 485, 342, 318, 495, 562, 368, 415]
exportqrcode(codes)

qrcodes

RexWzh commented 1 year ago

BTW, there are two keywords should be replaced in version 2.0.0.

exportqrcode( message::AbstractString
             , path::AbstractString = "qrcode.png"
             ; eclevel::ErrCorrLevel = Medium()
             , version::Int = 0
             , mode::Mode = Numeric()
             , mask::Int = -1
             , width::Int = 4
             , compact::Bool = false
             , targetsize::Int = 0
             , pixels::Int = 160)

compact is equivalent to width=0, and targetsize can be replaced by pixels while the latter is easier to understand.