Skip to content

Commit

Permalink
add init functions for generating char arrays externally
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Jul 27, 2019
1 parent 585abdf commit 8039d93
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "UnicodeGraphics"
uuid = "ebadf6b4-db70-5817-83da-4a19ad584e34"
authors = ["Rafael Schouten <[email protected]>"]
version = "0.1.0"
version = "0.1.2"

[compat]
julia = "1"
Expand Down
20 changes: 10 additions & 10 deletions src/UnicodeGraphics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export blockize, brailize, blockize!, brailize!
brailize(a, cutoff=0)
Convert an array to a block unicode string, filling values above the cutoff point.
"""
blockize(a, cutoff=0) = begin
yrange, xrange = axes(a)
out = Array{Char,2}(undef, length(xrange) + 1, (length(yrange) - 1) ÷ 2 + 1)
blockize!(out, a, cutoff)
end
blockize(a, cutoff=0) = blockize!(initblock(size(a)), a, cutoff)

# x and y are inverted: repl rows are columns.
initblock((y, x)) = initblock(y, x)
initblock(y, x) = Array{Char,2}(undef, x + 1, (y - 1) ÷ 2 + 1)

"""
blockize!(out, a, cutoff=0)
Expand Down Expand Up @@ -54,11 +54,11 @@ const braile_hex = ((0x01, 0x08), (0x02, 0x10), (0x04, 0x20), (0x40, 0x80))
brailize(a, cutoff=0)
Convert an array to a braile unicode string, filling values above the cutoff point.
"""
brailize(a, cutoff=0) = begin
yrange, xrange = axes(a)
out = Array{Char,2}(undef, (length(xrange) - 1) ÷ 2 + 2, (length(yrange) - 1) ÷ 4 + 1)
brailize!(out, a, cutoff)
end
brailize(a, cutoff=0) = brailize!(initbraile(size(a)), a, cutoff)

# x and y are inverted: repl rows are columns.
initbraile((y, x)) = initbraile(y, x)
initbraile(y, x) = Array{Char,2}(undef, (x - 1) ÷ 2 + 2, (y - 1) ÷ 4 + 1)

"""
brailize!(out, a, cutoff=0)
Expand Down
6 changes: 2 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using UnicodeGraphics,
OffsetArrays,
Test
using UnicodeGraphics, OffsetArrays, Test

pac = [0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0;
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0;
Expand Down Expand Up @@ -83,7 +81,7 @@ block_ghost =
██▀███▀▀███▀██
▀ ▀▀ ▀▀ ▀\0"""

test_ghost = blockize(OffsetArray(ghost[3:15, 4:17], 3:15, 4:17), 0.5, )
test_ghost = blockize(OffsetArray(ghost[3:15, 4:17], 3:15, 4:17), 0.5)
@test test_ghost == block_ghost
println(test_ghost, "\n\n", block_ghost, "\n\n")

Expand Down

2 comments on commit 8039d93

@rafaqz
Copy link
Collaborator Author

@rafaqz rafaqz commented on 8039d93 Jul 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

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/2319

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 Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.2 -m "<description of version>" 8039d93e848952171c1b279de44bb39377760740
git push origin v0.1.2

Also, note the warning: Version 0.1.2 skips over 0.1.1
This can be safely ignored. However, if you want to fix this you can do so. Call register() again after making the fix. This will update the Pull request.

Please sign in to comment.