You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# update docstring in src/images.jl when changing this default
30
+
constDEFAULT_BACKGROUND_COLOR=RGBA(0, 0, 0, 0)
31
+
constDEFAULT_BORDER_COLOR=RGB(0, 0, 0)
32
+
const DEFAULT_SCALE =1
33
+
const DEFAULT_BORDER =0
34
+
const DEFAULT_PAD=0
35
35
36
36
## Top-level function that handles argument errors, eagerly promotes types and allocates output buffer
37
37
38
38
function SparseMatrixColorings.show_colors(
39
39
res::AbstractColoringResult;
40
40
colorscheme=nothing,
41
-
background::Colorant=DEFAULT_BACKGROUND, # color used for zero matrix entries and pad
41
+
background_color::Colorant=DEFAULT_BACKGROUND_COLOR, # color used for zero matrix entries and pad
42
+
border_color::Colorant=DEFAULT_BORDER_COLOR, # color used for zero matrix entries and pad
42
43
scale::Int=DEFAULT_SCALE, # scale size of matrix entries to `scale × scale` pixels
44
+
border::Int=DEFAULT_BORDER, # border around matrix entries
43
45
pad::Int=DEFAULT_PAD, # pad between matrix entries
44
46
warn::Bool=true,
45
47
)
46
48
scale <1&&throw(ArgumentError("`scale` has to be ≥ 1."))
49
+
border <0&&throw(ArgumentError("`border` has to be ≥ 0."))
47
50
pad <0&&throw(ArgumentError("`pad` has to be ≥ 0."))
48
51
49
52
if!isnothing(colorscheme)
50
53
if warn &&ncolors(res) >length(colorscheme)
51
54
@warn"`show_colors` will reuse colors since the provided `colorscheme` has $(length(colorscheme)) colors and the matrix needs $(ncolors(res)). You can turn off this warning via the keyword argument `warn = false`, or choose a larger `colorscheme` from ColorSchemes.jl."
Copy file name to clipboardExpand all lines: src/show_colors.jl
+7-5Lines changed: 7 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -5,19 +5,21 @@
5
5
6
6
Create a visualization for an [`AbstractColoringResult`](@ref), with the help of the [JuliaImages](https://juliaimages.org) ecosystem.
7
7
8
-
- For `:column` or `:row` colorings, it returns a tuple `(A_img, B_img)`.
9
-
- For `:bidirectional` colorings, it returns a tuple `(A_img, Br_img, Bc_img)`.
8
+
- For `:column` or `:row` colorings, it returns a couple `(A_img, B_img)`.
9
+
- For `:bidirectional` colorings, it returns a 4-tuple `(Ar_img, Ac_img, Br_img, Bc_img)`.
10
10
11
11
!!! warning
12
12
This function is implemented in a package extension, using it requires loading [Colors.jl](https://github.com/JuliaGraphics/Colors.jl).
13
13
14
14
# Keyword arguments
15
15
16
16
- `colorscheme`: colors used for non-zero matrix entries. This can be a vector of `Colorant`s or a subsampled scheme from [ColorSchemes.jl](https://github.com/JuliaGraphics/ColorSchemes.jl).
17
-
- `background::Colorant`: color used for zero matrix entries and pad. Defaults to `RGBA(0,0,0,0)`, a transparent background.
18
-
- `scale::Int`: scale the size of matrix entries to `scale × scale` pixels. Defaults to `1`.
17
+
- `background_color::Colorant`: color used for zero matrix entries and pad. Defaults to `RGBA(0,0,0,0)`, a transparent background.
18
+
- `border_color::Colorant`: color used around matrix entries. Defaults to `RGB(0, 0, 0)`, a black border.
19
+
- `scale::Int`: scale the size of matrix entries to `scale × scale` pixels. Defaults to `1`.
20
+
- `border::Int`: set border width around matrix entries, in pixles. Defaults to `0`.
19
21
- `pad::Int`: set padding between matrix entries, in pixels. Defaults to `0`.
20
22
21
-
For a matrix of size `(m, n)`, the resulting output will be of size `(m * (scale + pad) + pad, n * (scale + pad) + pad)`.
23
+
For a matrix of size `(m, n)`, the resulting output will be of size `(m * (scale + 2border + pad) + pad, n * (scale + 2border + pad) + pad)`.
0 commit comments