local function blend_colors(fg, bg, alpha) -- fg, bg are hex colors as strings (e.g., "#a1112a") -- alpha is a value between 0 (fully transparent) and 1 (fully opaque) local function hex_to_rgb(hex) return tonumber(hex:sub(2, 3), 16), tonumber(hex:sub(4, 5), 16), tonumber(hex:sub(6, 7), 16) end local function rgb_to_hex(r, g, b) return string.format("#%02x%02x%02x", r, g, b) end local r1, g1, b1 = hex_to_rgb(fg) local r2, g2, b2 = hex_to_rgb(bg) local r = math.floor(r1 * alpha + r2 * (1 - alpha)) local g = math.floor(g1 * alpha + g2 * (1 - alpha)) local b = math.floor(b1 * alpha + b2 * (1 - alpha)) return rgb_to_hex(r, g, b) end return { blend_colors = blend_colors, }