Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): add lightness option for transparent bg #75

Merged
merged 1 commit into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lua/mellifluous/colors/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ function M.get_colors()

colors = apply_color_overrides(colors)
ensure_correct_color_types(colors)
if
config.transparent_background
and config.transparent_background.lightness
and type(config.transparent_background.lightness) == "function"
then
colors.bg = colors.bg:with_lightness(config.transparent_background.lightness(colors.bg))
end

colors = require("mellifluous.colors.shades").extend_with_shades(colors)

Expand Down
19 changes: 19 additions & 0 deletions lua/mellifluous/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ local function get_default_config()
},
transparent_background = {
enabled = false,
lightness = function(bg) -- used for bg shades
-- This method tries to keep brighter colorsets bright and
-- dimmer colorsets dim and still lighten the shades up so that
-- the colorsets have more chance to look good with transparent
-- background on brighter wallpapers.
local old_lightness = bg:get_hsl().l
local threshold = 20
local baseline = 10
if old_lightness < threshold then
-- We will assume that the dimmest of transparent
-- background over users wallpaper is at least of baseline
-- lightness. Presuming old range is [0, threshold], let's
-- position the lightness relatively in a new range of
-- [baseline, threshold].
local position = old_lightness / threshold
local new_lightness = baseline + ((threshold - baseline) * position)
return new_lightness
end
end,
floating_windows = true,
telescope = true,
file_tree = true,
Expand Down
Loading