From d012f93c881ff830223cc34da3e94d20b5c08b3f Mon Sep 17 00:00:00 2001 From: Ramojus Lapinskas Date: Sat, 26 Oct 2024 16:41:11 +0300 Subject: [PATCH] fix(shader): don't remove hue when it doesn't change in `replicate_shade()` --- lua/mellifluous/utils/shader.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lua/mellifluous/utils/shader.lua b/lua/mellifluous/utils/shader.lua index 0bcdcf9..c6373c0 100644 --- a/lua/mellifluous/utils/shader.lua +++ b/lua/mellifluous/utils/shader.lua @@ -17,12 +17,14 @@ function M.replicate_shade(from_color, to_color, target) local target_hsl = target:get_hsl() if target_hsl.h and from_hsl.h and to_hsl.h then target_hsl.h = clip(target_hsl.h + to_hsl.h - from_hsl.h, 0, 360) - elseif to_hsl.h == nil then - target_hsl.h = nil elseif from_hsl.h ~= to_hsl.h then - require("mellifluous").return_error( - "this shade changes hue, but at least one of the colors is neutral, without hue" - ) + if to_hsl.h == nil then + target_hsl.h = nil + else + require("mellifluous").return_error( + "this shade changes hue, but at least one of the colors is neutral, without hue" + ) + end end target_hsl.s = clip(target_hsl.s + to_hsl.s - from_hsl.s, 0, 100) target_hsl.l = clip(target_hsl.l + to_hsl.l - from_hsl.l, 0, 100)