Skip to content

Commit 838d19e

Browse files
committed
UnicodePlots: use normal text color where useful
1 parent 9943b08 commit 838d19e

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

ext/GridVisualizeUnicodePlotsExt.jl

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ function reveal(ctx::SubVisualizer, TP::Type{UnicodePlotsType})
4040
end
4141

4242

43-
function region_legend!(canvas, title, x, y, colors)
43+
function region_legend!(canvas, title, x, y, colors, text_color)
4444
# legend by annotate!
4545
for (i, char) in enumerate(title)
46-
UnicodePlots.char_point!(canvas, x + i - 1, y, char, UInt32(0), false)
46+
UnicodePlots.char_point!(canvas, x + i - 1, y, char, text_color, false)
4747
end
4848
startx = x + length(title)
4949
for r in 1:length(colors)
@@ -194,16 +194,18 @@ function gridplot!(ctx, TP::Type{UnicodePlotsType}, ::Type{Val{2}}, grid)
194194
)
195195
end
196196

197-
region_legend!(canvas, "cell regions: ", 2, 1, colors)
198-
region_legend!(canvas, "bface regions:", 2, 2, bcolors)
197+
text_color = UnicodePlots.ansi_color(:normal)
198+
199+
region_legend!(canvas, "cell regions: ", 2, 1, colors, text_color)
200+
region_legend!(canvas, "bface regions:", 2, 2, bcolors, text_color)
199201

200202
# corner coordinates
201203
ex = extrema(view(coords, 1, :))
202204
ey = extrema(view(coords, 2, :))
203-
UnicodePlots.annotate!(canvas, ex[1], ey[1], "$(ex[1])", UInt32(0), false; valign = :top)
204-
UnicodePlots.annotate!(canvas, ex[2], ey[1], "$(ex[2])", UInt32(0), false; valign = :top, halign = :right)
205-
UnicodePlots.annotate!(canvas, ex[1] - 1.5 * padding, ey[1], "$(ey[1])", UInt32(0), false; halign = :left)
206-
UnicodePlots.annotate!(canvas, ex[1] - 1.5 * padding, ey[2], "$(ey[2])", UInt32(0), false; halign = :left)
205+
UnicodePlots.annotate!(canvas, ex[1], ey[1], "$(ex[1])", text_color, false; valign = :top)
206+
UnicodePlots.annotate!(canvas, ex[2], ey[1], "$(ex[2])", text_color, false; valign = :top, halign = :right)
207+
UnicodePlots.annotate!(canvas, ex[1] - 1.5 * padding, ey[1], "$(ey[1])", text_color, false; halign = :left)
208+
UnicodePlots.annotate!(canvas, ex[1] - 1.5 * padding, ey[2], "$(ey[2])", text_color, false; halign = :left)
207209

208210
# plot
209211
ctx[:figure] = UnicodePlots.Plot(canvas; title = ctx[:title])
@@ -213,6 +215,7 @@ end
213215

214216
function gridplot!(ctx, TP::Type{UnicodePlotsType}, ::Type{Val{1}}, grid)
215217
UnicodePlots = ctx[:Plotter]
218+
text_color = UnicodePlots.ansi_color(:normal)
216219

217220
# find bounding box
218221
coords = grid[Coordinates]
@@ -273,7 +276,7 @@ function gridplot!(ctx, TP::Type{UnicodePlotsType}, ::Type{Val{1}}, grid)
273276
end
274277
end
275278
for j in 1:nnodes
276-
UnicodePlots.annotate!(canvas, coords[1, j], 0.4, "", UInt32(0), false)
279+
UnicodePlots.annotate!(canvas, coords[1, j], 0.4, "", text_color, false)
277280
end
278281

279282
# plot boundary nodes with bregion_cmap colors
@@ -296,13 +299,14 @@ function gridplot!(ctx, TP::Type{UnicodePlotsType}, ::Type{Val{1}}, grid)
296299
UnicodePlots.annotate!(canvas, coords[1, bfacenodes[1, j]], 0.4, "", UInt32(uint_color), false)
297300
end
298301

299-
region_legend!(canvas, "cell regions: ", 2, 1, colors)
300-
region_legend!(canvas, "bface regions:", 2, 2, bcolors)
302+
303+
region_legend!(canvas, "cell regions: ", 2, 1, colors, text_color)
304+
region_legend!(canvas, "bface regions:", 2, 2, bcolors, text_color)
301305

302306

303307
ex = extrema(view(coords, 1, :))
304-
UnicodePlots.annotate!(canvas, 0, 0.1, "$(ex[1])", UInt32(0), false)
305-
UnicodePlots.annotate!(canvas, ex[2], 0.1, "$(ex[2])", UInt32(0), false)
308+
UnicodePlots.annotate!(canvas, 0, 0.1, "$(ex[1])", text_color, false)
309+
UnicodePlots.annotate!(canvas, ex[2], 0.1, "$(ex[2])", text_color, false)
306310

307311
# plot
308312
ctx[:figure] = UnicodePlots.Plot(canvas; title = ctx[:title])

0 commit comments

Comments
 (0)