Skip to content

Commit 9cf8e3d

Browse files
committed
add tests for ascii_display
1 parent 6f760ef commit 9cf8e3d

12 files changed

+137
-32
lines changed

AsciiPixel/Project.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@ version = "0.1.0"
55
[deps]
66
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
77
ImageBase = "c817782e-172a-44cc-b673-b171935fbb9e"
8-
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
98

109
[compat]
11-
Crayons = "0.5, 1, 2, 3, 4"
10+
Crayons = "1 - 4"
1211
ImageBase = "0.1"
13-
ImageCore = "0.9"
1412
julia = "1.6"
1513

1614
[extras]
1715
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"
1816
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
17+
ImageTransformations = "02fcd773-0e25-5acc-982a-7f6622650795"
1918
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
2019
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
2120
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2221
TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990"
2322

2423
[targets]
25-
test = ["ImageIO", "ImageMagick", "OffsetArrays", "ReferenceTests", "Test", "TestImages"]
24+
test = ["ImageIO", "ImageMagick", "ImageTransformations", "OffsetArrays", "ReferenceTests", "Test", "TestImages"]

AsciiPixel/src/AsciiPixel.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
module AsciiPixel
22

3-
using ImageBase: restrict
4-
using ImageCore
3+
using ImageBase
54
using Crayons
65

76
export ascii_display
87

98
include("colorant2ansi.jl")
10-
include("ascii_encode.jl")
9+
include("ascii.jl")
1110

1211
const colormode = Ref{TermColorDepth}(TermColor8bit())
1312

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,30 +210,33 @@ downsampled to fit into the display (using `restrict`).
210210

211211
# colorant matrix
212212
function ascii_display(
213-
io::IO,
214-
img::AbstractMatrix{<:Colorant},
215-
colordepth::TermColorDepth,
216-
maxsize::Tuple = displaysize(io);
217-
trail_nl::Bool = false)
213+
io::IO,
214+
img::AbstractMatrix{<:Colorant},
215+
colordepth::TermColorDepth,
216+
maxsize::Tuple = displaysize(io);
217+
kwargs...
218+
)
218219
io_h, io_w = maxsize
219220
img_h, img_w = map(length, axes(img))
220221
downscale = img_h <= io_h - 4 && 2img_w <= io_w ? downscale_big : downscale_small
221222
img, enc = downscale(img, io_h - 4, io_w)
222-
ascii_encode(io, enc, colordepth, img; trail_nl)
223+
ascii_encode(io, enc, colordepth, img; kwargs...)
223224
io
224225
end
225226

226227
# colorant vector
227228
function ascii_display(
228-
io::IO,
229-
img::AbstractVector{<:Colorant},
230-
colordepth::TermColorDepth,
231-
maxsize::Tuple = displaysize(io))
229+
io::IO,
230+
img::AbstractVector{<:Colorant},
231+
colordepth::TermColorDepth,
232+
maxsize::Tuple = displaysize(io);
233+
kwargs...
234+
)
232235
io_h, io_w = maxsize
233236
img_w = length(img)
234237
downscale = 3img_w <= io_w ? downscale_big : downscale_small
235238
img, enc = downscale(img, io_w)
236-
ascii_encode(io, enc, colordepth, img)
239+
ascii_encode(io, enc, colordepth, img; kwargs...)
237240
io
238241
end
239242

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
2+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
3+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
4+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
5+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
6+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
7+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
8+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
2+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
3+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
4+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
5+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
6+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
7+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
8+
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

0 commit comments

Comments
 (0)