Skip to content

Commit 404783b

Browse files
authored
small updates (#402)
1 parent 8402d3a commit 404783b

17 files changed

+46
-39
lines changed

ext/FreeTypeExt.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# adapted from github.com/JuliaGraphics/FreeTypeAbstraction.jl/blob/master/src/rendering.jl
2-
# credits to the `FreeTypeAbstraction` authors
2+
# credits to the `FreeTypeAbstraction` authors (@SimonDanisch, @jkrumbiegel).
33

44
module FreeTypeExt
55

@@ -24,7 +24,7 @@ end
2424

2525
mutable struct FTFont
2626
ft_ptr::FT_Face
27-
lock::ReentrantLock # lock this for the duration of any FT operation on ft_ptr
27+
lock::ReentrantLock # lock this for the duration of any FT operation on ft_ptr
2828
function FTFont(ft_ptr::FT_Face)
2929
face = new(ft_ptr, ReentrantLock())
3030
finalizer(safe_free, face)
@@ -45,7 +45,7 @@ family_name(font::FTFont) = lowercase(ft_property(font, :family_name))
4545
style_name(font::FTFont) = lowercase(ft_property(font, :style_name))
4646
Base.propertynames(font::FTFont) = fieldnames(FT_FaceRec)
4747

48-
# C interop
48+
# c interoperability
4949
Base.cconvert(::Type{FT_Face}, font::FTFont) = font
5050
Base.unsafe_convert(::Type{FT_Face}, font::FTFont) = font.ft_ptr
5151

@@ -79,7 +79,7 @@ add_mono(fts...) = tuple(map(x -> x * "Mono", fts)..., fts...)
7979
fallback_fonts() =
8080
# those fallback fonts are likely to fail braille characters
8181
if Sys.islinux()
82-
add_mono("DejaVu Sans ", "Ubuntu ", "Noto ", "Free", "Liberation ")
82+
add_mono("DejaVu Sans ", "Ubuntu ", "Noto ", "Free", "Liberation ") # NOTE: trailing space intended
8383
elseif Sys.isbsd()
8484
("Courier New", "Helvetica")
8585
elseif Sys.iswindows()
@@ -274,16 +274,16 @@ one_or_typemax(::Type{T}) where {T<:Union{Real,Colorant}} =
274274
Render `str` into `img` using the font `face` of size `pixelsize` at coordinates `y0,x0`.
275275
Uses the conventions of freetype.org/freetype2/docs/glyphs/glyphs-3.html
276276
# Arguments
277-
* `y0,x0`: origin is in upper left with positive `y` going down
278-
* `fcolor`: foreground color; AbstractVector{T}, typemax(T) for T<:Integer, otherwise one(T)
279-
* `gcolor`: background color; AbstractVector{T}, typemax(T) for T<:Integer, otherwise one(T)
280-
* `bcolor`: canvas background color; set to `nothing` for transparent
281-
* `halign`: :hleft, :hcenter, or :hright
282-
* `valign`: :vtop, :vcenter, :vbaseline, or :vbttom
283-
* `bbox_glyph`: glyph bounding box color (debugging)
284-
* `bbox`: bounding box color (debugging)
285-
* `gstr`: background string or array of chars (for background sizing)
286-
* `incx`: extra x spacing
277+
- `y0,x0`: origin is in upper left with positive `y` going down.
278+
- `fcolor`: foreground color; AbstractVector{T}, typemax(T) for T<:Integer, otherwise one(T).
279+
- `gcolor`: background color; AbstractVector{T}, typemax(T) for T<:Integer, otherwise one(T).
280+
- `bcolor`: canvas background color; set to `nothing` for transparent.
281+
- `halign`: :hleft, :hcenter, or :hright.
282+
- `valign`: :vtop, :vcenter, :vbaseline, or :vbttom.
283+
- `bbox_glyph`: glyph bounding box color (debugging).
284+
- `bbox`: bounding box color (debugging).
285+
- `gstr`: background string or array of chars (for background sizing).
286+
- `incx`: extra x spacing.
287287
"""
288288
function UnicodePlots.render_string!(
289289
img::AbstractMatrix{T},
@@ -455,7 +455,7 @@ add_recursive(result, path) =
455455
function __init__()
456456
ft_init()
457457
atexit(ft_done)
458-
# This method of finding fonts might not work for exotic platforms,
458+
# this method of finding fonts might not work for exotic platforms,
459459
# so we supply a way to help it with an environment variable.
460460
font_paths = if Sys.isapple() # COV_EXCL_LINE
461461
[

src/canvas/asciicanvas.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""
2-
As the name suggests the `AsciiCanvas` only uses ASCII characters to draw it's content.
2+
As the name suggests the `AsciiCanvas` only uses ASCII characters to draw its content.
33
Naturally, it doesn't look quite as nice as the Unicode-based ones.
44
However, in some situations it might yield better results.
55
Printing plots to a file is one of those situations.
66
7-
The AsciiCanvas is best utilized in combination with `lineplot`.
7+
The AsciiCanvas is best used in combination with `lineplot`.
88
For `scatterplot` we suggest to use the `DotCanvas` instead.
99
"""
1010
struct AsciiCanvas{YS<:Function,XS<:Function} <: LookupCanvas

src/canvas/blockcanvas.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
The `BlockCanvas` is also Unicode-based.
33
It has half the resolution of the `BrailleCanvas`.
44
In contrast to BrailleCanvas, the pixels don't have visible spacing between them.
5-
This canvas effectively turns every character into 4 pixels that can individually be manipulated using binary operations.
5+
This canvas effectively turns every character into four pixels that can individually be manipulated using binary operations.
66
"""
77
struct BlockCanvas{YS<:Function,XS<:Function} <: LookupCanvas
88
grid::Transpose{UInt16,Matrix{UInt16}}

src/canvas/braillecanvas.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# braille dots composing
1+
# braille dots composing the character '⣿'
22
const BRAILLE_SIGNS = UnicodeType.([
33
'' ''
44
'' ''
@@ -9,7 +9,7 @@ const BRAILLE_SIGNS = UnicodeType.([
99
"""
1010
The type of canvas with the highest resolution for Unicode-based plotting.
1111
It uses the Unicode characters for the Braille symbols to represent individual pixel.
12-
This effectively turns every character into 8 pixels that can individually be manipulated using binary operations.
12+
This effectively turns every character into eight pixels that can individually be manipulated using binary operations.
1313
"""
1414
struct BrailleCanvas{YS<:Function,XS<:Function} <: Canvas
1515
grid::Transpose{UnicodeType,Matrix{UnicodeType}}

src/canvas/densitycanvas.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const DEN_SIGNS = Ref((' ', '', '', '', ''))
22

33
"""
4-
Unlike the `BrailleCanvas`, the density canvas does not simply mark a "pixel" as set.
4+
Unlike the `BrailleCanvas`, the density canvas does not simply mark a pixel as set.
55
Instead it increments a counter per character that keeps track of the frequency of pixels drawn in that character.
66
Together with a variable that keeps track of the maximum frequency, the canvas can thus draw the density of datapoints.
77
"""

src/canvas/dotcanvas.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""
2-
Similar to the `AsciiCanvas`, the `DotCanvas` only uses ASCII characters to draw it's content.
2+
Similar to the `AsciiCanvas`, the `DotCanvas` only uses ASCII characters to draw its content.
33
Naturally, it doesn't look quite as nice as the Unicode-based ones.
44
However, in some situations it might yield better results.
55
Printing plots to a file is one of those situations.
66
7-
The DotCanvas is best utilized in combination with `scatterplot`.
7+
The DotCanvas is best used in combination with `scatterplot`.
88
For `lineplot` we suggest to use the `AsciiCanvas` instead.
99
"""
1010
struct DotCanvas{YS<:Function,XS<:Function} <: LookupCanvas

src/canvas/lookupcanvas.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"""
2+
Supertype for Look-Up Table (LUT) encoded canvases.
3+
"""
14
abstract type LookupCanvas <: Canvas end
25

36
function CreateLookupCanvas(

src/description.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Adds default keywords to a function signature, in a docstring.
164164
165165
# Arguments
166166
167-
- `extra::NamedTuple`: add extra keywords in the form `keyword=value`.
167+
- `extra::NamedTuple`: add extra keywords in the form `keyword = value`.
168168
- `default::Tuple`: default `UnicodePlots` keywords.
169169
- `add::Tuple`: add extra symbols, not listed in `default` but present in `KEYWORDS`.
170170
- `remove::Tuple`: remove symbols from `default`.
@@ -190,7 +190,7 @@ Defines arguments for docstring genreration.
190190
191191
# Arguments
192192
193-
- `desc::NamedTuple`: add argument description in the form `arg=desc`.
193+
- `desc::NamedTuple`: add argument description in the form `arg = desc`.
194194
- `default::Tuple`: default `UnicodePlots` keywords.
195195
- `add::Tuple`: add extra symbols, not listed in `default` but present in `DESCRIPTION`.
196196
- `remove::Tuple`: remove symbols from `default`.

src/graphics/imagegraphics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ end
2424
@inline nrows(c::ImageGraphics) = first(c.encoded_size)
2525
@inline ncols(c::ImageGraphics) = last(c.encoded_size)
2626

27-
# # generic functions for `ImageInTerminalExt`
27+
# # generic functions for `ImageInTerminalExt`
2828
function terminal_specs end
2929
function sixel_encode end
3030
function imshow end

src/interface/barplot.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $(arguments(
2626
dict = "a dictionary in which the keys will be used as `text` and the values will be used as `heights`",
2727
xscale = "`Function` or `Symbol` to transform the bar length before plotting: this effectively scales the `x`-axis without influencing the captions of the individual bars (use `xscale = :log10` for logscale)",
2828
color = "`Vector` of colors, or scalar - $(DESCRIPTION[:color])",
29-
maximum = "optional maximal height"
29+
maximum = "optional maximal height",
3030
); remove = (:xlim, :ylim, :yscale, :height, :grid), add = (:symbols,),
3131
))
3232

src/interface/heatmap.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ $(arguments(
2020
xfact = "scale for the `x` coordinate (defaults to 0 - i.e. each column in `A` maps to one unit, `x` origin starting at 1). If set to anything else, the x origin will start at 0",
2121
yoffset = "plotting offset for the `y` coordinate (after scaling)",
2222
xoffset = "plotting offset for the `x` coordinate (after scaling)",
23-
array = "use array display convention (origin at the North-West corner of the plot, hence flipping `y` versus regular plots)"
23+
array = "use array display convention (origin at the North-West corner of the plot, hence flipping `y` versus regular plots)",
2424
); add = (Z_DESCRIPTION..., :fix_ar)
2525
))
2626
@@ -160,7 +160,7 @@ function heatmap(
160160
# for small plots, don't show colorbar by default
161161
get(pkw, :colorbar, false)
162162
else
163-
# show colorbar by default, unless set to false, or labels == false
163+
# show colorbar by default, unless set to false, or `labels = false`
164164
get(pkw, :colorbar, labels)
165165
end
166166

src/interface/imageplot.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
imageplot(img; kw...)
33
4-
Plot an image using `ImageInTerminal` (`sixel`s are supported if the terminal emulator supports it).
4+
Plot an image using `ImageInTerminal` (`sixel`s are supported if the terminal emulator supports them).
55
66
# Usage
77

src/interface/scatterplot.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Draws the given points on a new canvas.
1010
1111
The first (optional) vector `x` should contain the horizontal positions for all the points.
1212
The second vector `y` should then contain the corresponding vertical positions respectively.
13-
This means that the two vectors must be of the same length and ordering.
13+
This means that the two vectors must be of same length and ordering.
1414
1515
# Usage
1616

src/interface/stairs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Draws a staircase plot on a new canvas.
88
99
The first (optional) vector `x` should contain the horizontal positions for all the points.
1010
The second vector `y` should then contain the corresponding vertical positions respectively.
11-
This means that the two vectors must be of the same length and ordering.
11+
This means that the two vectors must be of same length and ordering.
1212
1313
# Usage
1414

src/interface/surfaceplot.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ end
110110
Y::AbstractVecOrMat,
111111
Z::AbstractVecOrMat,
112112
H::Union{AbstractVecOrMat,Nothing} = nothing;
113-
color::UserColorType = nothing, # NOTE: nothing as default (uses colormap), but allow single color
113+
color::UserColorType = nothing, # NOTE: `nothing` as default (uses a colormap), but allow a single color
114114
colormap = KEYWORDS.colormap,
115115
lines::Bool = false,
116116
zlim = KEYWORDS.zlim,

src/show.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ end
144144

145145
Base.show(io::IO, p::Plot) = _show(io, print, print_color, p)
146146

147+
"""
148+
Display a `Plot` object to a terminal emulator.
149+
"""
147150
function _show(end_io::IO, print_nocol, print_color, p::Plot)
148151
buf = PipeBuffer() # buffering, for performance
149152
io_color = get(end_io, :color, false)
@@ -406,7 +409,7 @@ function save_image end
406409
"""
407410
png_image(p::Plot, font = nothing, pixelsize = 32, transparent = true, foreground = nothing, background = nothing, bounding_box = nothing, bounding_box_glyph = nothing)
408411
409-
Render `png` image.
412+
Renders a `png` image.
410413
411414
# Arguments
412415
- `pixelsize::Integer = 32`: controls the image size scaling.

src/volume.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Computes the perspective projection matrix (see songho.ca/opengl/gl_projectionma
7272
# Arguments
7373
7474
- `l`: left coordinate of the vertical clipping plane.
75-
- `r` : right coordinate of the vertical clipping plane.
75+
- `r`: right coordinate of the vertical clipping plane.
7676
- `b`: bottom coordinate of the horizontal clipping plane.
7777
- `t`: top coordinate of the horizontal clipping plane.
7878
- `n`: distance to the near depth clipping plane.
@@ -112,7 +112,7 @@ Computes the orthographic projection matrix (see songho.ca/opengl/gl_projectionm
112112
# Arguments
113113
114114
- `l`: left coordinate of the vertical clipping plane.
115-
- `r` : right coordinate of the vertical clipping plane.
115+
- `r`: right coordinate of the vertical clipping plane.
116116
- `b`: bottom coordinate of the horizontal clipping plane.
117117
- `t`: top coordinate of the horizontal clipping plane.
118118
- `n`: distance to the near depth clipping plane.
@@ -138,7 +138,7 @@ ortho(l, r, b, t, n, f) = *(
138138
139139
# Description
140140
141-
Computes data center, minimum and maximum points, and cube diagonal.
141+
Computes data center, minimum and maximum points, and cube diagonal length.
142142
"""
143143
function ctr_len_diag(x, y, z)
144144
mx, Mx = nanless_extrema(x)
@@ -238,7 +238,7 @@ struct MVP{E,T}
238238
is_ortho = projection (:ortho, :orthographic)
239239
ctr, mini, maxi, len, diag = ctr_len_diag(x, y, z)
240240

241-
# half the diagonal (cam distance to the center)
241+
# half the diagonal (camera distance to the center)
242242
disto = dist = (diag / 2) / zoom
243243
distp = disto / 2
244244

@@ -362,7 +362,7 @@ axis_line(tr, proj, start::AbstractVector{T}, stop::AbstractVector{T}) where {T}
362362
# Description
363363
364364
Draws (X, Y, Z) cartesian coordinates axes in (R, G, B) colors, at position `p = (x, y, z)`.
365-
If `p = (x, y)` is given, draws at screen coordinates.
365+
If `p = (x, y)` is given, draws at screen coordinates instead.
366366
"""
367367
function draw_axes!(plot, x::T, y::T, z::T, scale = T(0.25)) where {T<:AbstractFloat}
368368
tr = plot.projection
@@ -388,6 +388,7 @@ function draw_axes!(plot, x::T, y::T, z::T, scale = T(0.25)) where {T<:AbstractF
388388

389389
plot
390390
end
391+
391392
draw_axes!(plot, x::T, y::T, z::Nothing, args...) where {T<:AbstractFloat} =
392393
let (x, y, z) = transform_matrix(plot.projection, :ortho) \ SVector(x, y, T(0), T(1))
393394
draw_axes!(plot, x, y, z, args...)

0 commit comments

Comments
 (0)