Skip to content

Commit

Permalink
Slightly more flexible background color choice
Browse files Browse the repository at this point in the history
  • Loading branch information
jagot committed Jul 24, 2024
1 parent d11133e commit fbeed8b
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/Gruvbox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ const gruvbox_light_palette = Dict(
:orange_hi => "#af3a03"
)

function color_gruvbox(palette; use_alt_bg=true)
function color_gruvbox(palette; use_alt_bg=true, swap_bg=false, legend_alt_bg=false)
fg = parse(Colorant, palette[:fg])
fg_alt = parse(Colorant, palette[:fg4])
bg = parse(Colorant, palette[:bg])
bg_alt = parse(Colorant, palette[use_alt_bg ? :bg1 : :bg])
if swap_bg
bg,bg_alt = bg_alt,bg
end

color_cycle = [parse(Colorant, palette[c])
for c in [
Expand Down Expand Up @@ -163,27 +166,37 @@ function color_gruvbox(palette; use_alt_bg=true)
),
Legend = (
framecolor = fg,
backgroundcolor = bg_alt,
backgroundcolor = legend_alt_bg ? bg_alt : bg,
)
)
end

"""
color_gruvbox_light(; use_alt_bg=true)
color_gruvbox_light(; kwargs...)
Set up the light version of the Gruvbox color theme.
Keyword arguments:
Set up the light version of the Gruvbox color theme. Optionally, use a
slightly different background color for axes backgrounds, etc
(default).
- `use_alt_bg=true`: Use a slightly different background color inside
axes, etc.
- `swap_bg=false`: Interchange the background colors used for the
figure and axes etc.
- `legend_alt_bg=false`: Use the alternate background color for the
legend background. Which looks better depends on the legend is
inside the axis or outside it.
"""
color_gruvbox_light(;kwargs...) =
color_gruvbox(gruvbox_light_palette; kwargs...)

"""
color_gruvbox_dark(; use_alt_bg=true)
color_gruvbox_dark(; kwargs...)
Set up the dark version of the Gruvbox color theme.
Set up the dark version of the Gruvbox color theme. Optionally, use a
slightly different background color for axes backgrounds, etc
(default).
See [`color_gruvbox_light`](@ref) for the available keyword arguments.
"""
color_gruvbox_dark(;kwargs...) =
color_gruvbox(gruvbox_dark_palette; kwargs...)
Expand Down

0 comments on commit fbeed8b

Please sign in to comment.