Skip to content

Commit

Permalink
fix(shader): handle cases when one of the shade colors is NONE (trans…
Browse files Browse the repository at this point in the history
…parent)
  • Loading branch information
ramojus committed Oct 27, 2024
1 parent 7fbcccd commit 075fa4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions lua/mellifluous/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function M.load()
local colors = require("mellifluous.colors").get_colors()
local highlighter = require("mellifluous.utils.highlighter")

require("mellifluous.utils.shader").set_background_color(colors.bg)
require("mellifluous.highlights").set(highlighter, colors)
require("mellifluous.config").set_highlight_overrides(highlighter, colors)

Expand Down
11 changes: 11 additions & 0 deletions lua/mellifluous/utils/shader.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
local M = {}

local bg_color

local function clip(val, from, to)
if val > to then
return to
Expand All @@ -10,6 +12,11 @@ local function clip(val, from, to)
end

function M.replicate_shade(from_color, to_color, target)
-- assume bg_color for any transparent colors
from_color = from_color ~= "NONE" and from_color or bg_color
to_color = to_color ~= "NONE" and to_color or bg_color
target = target ~= "NONE" and target or bg_color

local from_hsl = from_color:get_hsl()
local to_hsl = to_color:get_hsl()
local color = require("mellifluous.color")
Expand Down Expand Up @@ -52,4 +59,8 @@ function M.get_higher_contrast(color, amount)
return color:darkened(amount)
end

function M.set_background_color(new_bg_color)
bg_color = new_bg_color
end

return M

0 comments on commit 075fa4b

Please sign in to comment.