-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
Add styles
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
test/testimages/*.png | ||
.vscode/ | ||
*.jl.cov | ||
*.jl.*.cov | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
name = "QRCoders" | ||
uuid = "f42e9828-16f3-11ed-2883-9126170b272d" | ||
authors = ["Jérémie Gillet <[email protected]> and contributors"] | ||
version = "1.0.1" | ||
version = "1.1.0" | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
[deps] | ||
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" | ||
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534" | ||
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19" | ||
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" | ||
|
||
[compat] | ||
FileIO = "1" | ||
ImageCore = "0.8, 0.9" | ||
ImageIO = "0.4, 0.5, 0.6" | ||
UnicodePlots = "2.12" | ||
julia = "1.3" | ||
|
||
[extras] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# style of QR code | ||
## support tables | ||
## 1. Unicode plot | ||
|
||
# 1. Unicode plot | ||
""" | ||
unicodeplot(mat::AbstractMatrix{Bool}; border=:none) | ||
Uses UnicodePlots.jl to draw the matrix. | ||
""" | ||
function unicodeplot(mat::AbstractMatrix{Bool}; border=:none) | ||
width, height = size(mat) | ||
return heatmap(mat; | ||
labels=false, | ||
border=border, | ||
colormap=:gray, | ||
width=width, | ||
height=height) | ||
end | ||
|
||
""" | ||
unicodeplot(message::AbstractString | ||
; border=:none) | ||
Uses UnicodePlots.jl to draw the QR code of `message`. | ||
""" | ||
function unicodeplot(message::AbstractString; border=:none) | ||
unicodeplot(qrcode(message;eclevel=Low(), compact=false, width=2); border=border) | ||
end | ||
|
||
## idea by @notinaboat | ||
const pixelchars = [' ', '▄', '▀', '█'] | ||
pixelchar(block::AbstractVector) = pixelchars[2 * block[1] + block[2] + 1] | ||
pixelchar(bit::Bool) = pixelchars[1 + 2 * bit] | ||
|
||
""" | ||
unicodeplotbychar(mat::AbstractMatrix) | ||
Plot of the QR code using Unicode characters. | ||
Note that `true` represents white and `false` represents black. | ||
""" | ||
function unicodeplotbychar(mat::AbstractMatrix) | ||
m = size(mat, 1) | ||
txt = @views join((join(pixelchar.(eachcol(mat[i:i+1, :]))) for i in 1:2:m & 1 ⊻ m), '\n') | ||
isodd(m) || return txt | ||
return @views txt * '\n' * join(pixelchar.(mat[m, :])) | ||
end | ||
|
||
""" | ||
unicodeplotbychar(message::AbstractString) | ||
Plot of the QR code using Unicode characters. | ||
Note that `true` represents black and `false` represents white in qrcode, | ||
which is the opposite of the image convention. | ||
""" | ||
function unicodeplotbychar(message::AbstractString) | ||
unicodeplotbychar(.! qrcode(message; eclevel=Low(), compact=false, width=2)) | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.jpg | ||
*.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Test for style of QR code | ||
@testset "Unicode plot" begin | ||
# by UnicodePlots | ||
alphabets = [join('0':'9'), keys(alphanumeric), join(Char.(0:255)), keys(kanji)] | ||
for alphabet in alphabets | ||
msg = join(rand(alphabet, 100)) | ||
canvas = unicodeplot(msg) | ||
end | ||
@test true | ||
|
||
# by Unicode characters | ||
alphabets = [join('0':'9'), keys(alphanumeric), join(Char.(0:255)), keys(kanji)] | ||
for alphabet in alphabets | ||
msg = join(rand(alphabet, 100)) | ||
canvas = unicodeplotbychar(msg) | ||
end | ||
@test true | ||
unicodeplotbychar("https://github.com/JuliaImages/QRCoders.jl") |> println | ||
end |
4 comments
on commit ba935ec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/69585
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:
git tag -a v1.1.0 -m "<description of version>" ba935ec773c334736b775bb9a0c3653adf3c9df6
git push origin v1.1.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request updated: JuliaRegistries/General/69585
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:
git tag -a v1.1.0 -m "<description of version>" ba935ec773c334736b775bb9a0c3653adf3c9df6
git push origin v1.1.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register branch=master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request updated: JuliaRegistries/General/69585
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:
git tag -a v1.1.0 -m "<description of version>" ba935ec773c334736b775bb9a0c3653adf3c9df6
git push origin v1.1.0
More styles for QRCoders.jl will be added in version 1.1.x.
@JuliaRegistrator register branch=master