Skip to content

Commit f64ef90

Browse files
committed
improve docs, reduce dependecies
1 parent 9cf8e3d commit f64ef90

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

AsciiPixel/src/ascii.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ Larger images are downscaled automatically using `restrict`.
2424
2525
Returns
2626
1. Downscaled image
27-
2. Selected encoder with `size` containing:
28-
1. number of lines in the vector.
27+
2. Selected encoder (big or small blocks) with `size` containing:
28+
1. number of lines in the Vector{String}.
2929
2. number of visible characters per line (the remaining are colorcodes).
3030
"""
3131
function downscale_small(img::AbstractMatrix{<:Colorant}, maxheight::Int, maxwidth::Int)
@@ -187,6 +187,7 @@ function ascii_encode(
187187
ret ? readlines(io) : nothing
188188
end
189189

190+
# uses a `PipeBuffer` as io and returns encoded data reading lines of this buffer
190191
ascii_encode(enc::SmallBlocks, args...) =
191192
ascii_encode(PipeBuffer(), enc, args...; ret=true)
192193

@@ -208,7 +209,6 @@ based on the current display size. The image will also be
208209
downsampled to fit into the display (using `restrict`).
209210
"""
210211

211-
# colorant matrix
212212
function ascii_display(
213213
io::IO,
214214
img::AbstractMatrix{<:Colorant},
@@ -224,7 +224,6 @@ function ascii_display(
224224
io
225225
end
226226

227-
# colorant vector
228227
function ascii_display(
229228
io::IO,
230229
img::AbstractVector{<:Colorant},
@@ -240,5 +239,6 @@ function ascii_display(
240239
io
241240
end
242241

242+
# ascii_display, using the default colormode
243243
ascii_display(io::IO, img::AbstractArray{<:Colorant}; kwargs...) =
244244
ascii_display(io, img, colormode[]; kwargs...)

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ version = "0.4.7"
44

55
[deps]
66
AsciiPixel = "d64ea8f1-9d40-4cda-bb88-5de2505cd5c8"
7+
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
78
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
8-
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
99
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1010

1111
[compat]
1212
AsciiPixel = "0.1"
13+
ColorTypes = "0.9 - 0.11"
1314
Crayons = "1 - 4"
14-
ImageCore = "0.9"
1515
Requires = "1"
1616
julia = "1.6"
1717

src/ImageInTerminal.jl

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module ImageInTerminal
22

33
using AsciiPixel
4-
using ImageCore
4+
using ColorTypes
55
using Requires
66
using Crayons
77

@@ -31,7 +31,12 @@ different encoding method, call `AsciiPixel.use_256()` or `AsciiPixel.use_24bit(
3131
"""
3232
enable_encoding() = (should_render_image[] = true)
3333

34-
function use_sixel(img::AbstractArray)
34+
"""
35+
choose_sixel(img::AbstractArray)
36+
37+
Choose to encode the image using sixels based on the size of the encoded image.
38+
"""
39+
function choose_sixel(img::AbstractArray)
3540
encoder_backend[] == :Sixel || return false
3641

3742
# Sixel requires at least 6 pixels in row direction and thus doesn't perform very well for vectors.
@@ -85,15 +90,19 @@ terminal colors (defaults to 256 colors).
8590
8691
If working in the REPL, the function tries to choose the encoding
8792
based on the current display size. The image will also be
88-
downsampled to fit into the display (using `restrict`).
93+
downsampled to fit into the display.
94+
95+
Supported encoding:
96+
- sixel (`Sixel` backend)
97+
- ascii (`AsciiPixel` backend)
8998
"""
9099

91100
function imshow(
92101
io::IO,
93102
img::AbstractArray{<:Colorant},
94103
maxsize::Tuple = displaysize(io)
95104
)
96-
if use_sixel(img)
105+
if choose_sixel(img)
97106
sixel_encode(io, img)
98107
else
99108
if ndims(img) > 2

test/runtests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using Test, TestImages, ReferenceTests
22
using OffsetArrays, SparseArrays
33
using CoordinateTransformations
4-
using ImageBase, ImageCore
54
using ImageTransformations
65
using ImageQualityIndexes
76
using ImageInTerminal
87
using ImageMagick
98
using AsciiPixel
9+
using ImageBase
1010
using Rotations
1111

1212
import ImageInTerminal: imshow
@@ -35,7 +35,7 @@ end
3535

3636
include(joinpath(dirname(pathof(AsciiPixel)), "..", "test", "common.jl"))
3737

38-
# deprecated functions
38+
# deprecated functions, kept for testing
3939
function imshow256(args...)
4040
old_colormode = AsciiPixel.colormode[]
4141
AsciiPixel.set_colordepth(8)
@@ -52,7 +52,7 @@ end
5252

5353
ImageInTerminal.encoder_backend[] = :ImageInTerminal # manually disable Sixel
5454
for t in tests
55-
@testset "$t" begin
55+
@testset "$t" begins
5656
include(t)
5757
end
5858
end

0 commit comments

Comments
 (0)