···3939local M = {}
40404141M.setup = function(dashboard)
4242- local color = require("thomasgen.util.color")
4242+ local color = require("util.color")
4343 local alpha = require("alpha")
44444545 local mocha = require("catppuccin.palettes").get_palette("mocha")
···11+local M = {}
22+33+-- Convert hex color to RGB values
44+local function hex_to_rgb(hex)
55+ hex = hex:gsub("#", "")
66+ return tonumber("0x" .. hex:sub(1, 2)), tonumber("0x" .. hex:sub(3, 4)), tonumber("0x" .. hex:sub(5, 6))
77+end
88+99+-- Convert RGB values to hex color
1010+local function rgb_to_hex(r, g, b)
1111+ return string.format("#%02X%02X%02X", r, g, b)
1212+end
1313+1414+-- Clamp a value between min and max
1515+local function clamp(value, min, max)
1616+ return math.min(math.max(value, min), max)
1717+end
1818+1919+-- Darken a color by a percentage (0-100)
2020+function M.darken(hex, percent)
2121+ if not hex or not percent then
2222+ return hex
2323+ end
2424+2525+ local r, g, b = hex_to_rgb(hex)
2626+ local factor = (100 - percent) / 100
2727+2828+ r = clamp(math.floor(r * factor), 0, 255)
2929+ g = clamp(math.floor(g * factor), 0, 255)
3030+ b = clamp(math.floor(b * factor), 0, 255)
3131+3232+ return rgb_to_hex(r, g, b)
3333+end
3434+3535+-- Lighten a color by a percentage (0-100)
3636+function M.lighten(hex, percent)
3737+ if not hex or not percent then
3838+ return hex
3939+ end
4040+4141+ local r, g, b = hex_to_rgb(hex)
4242+ local factor = 1 + (percent / 100)
4343+4444+ r = clamp(math.floor(r * factor), 0, 255)
4545+ g = clamp(math.floor(g * factor), 0, 255)
4646+ b = clamp(math.floor(b * factor), 0, 255)
4747+4848+ return rgb_to_hex(r, g, b)
4949+end
5050+5151+-- Blend two colors with a given weight (0-1)
5252+function M.blend(color1, color2, weight)
5353+ weight = weight or 0.5
5454+ local r1, g1, b1 = hex_to_rgb(color1)
5555+ local r2, g2, b2 = hex_to_rgb(color2)
5656+5757+ local r = math.floor(r1 * (1 - weight) + r2 * weight)
5858+ local g = math.floor(g1 * (1 - weight) + g2 * weight)
5959+ local b = math.floor(b1 * (1 - weight) + b2 * weight)
6060+6161+ return rgb_to_hex(r, g, b)
6262+end
6363+6464+-- Check if a color is light or dark
6565+function M.is_light(hex)
6666+ local r, g, b = hex_to_rgb(hex)
6767+ -- Using relative luminance formula
6868+ local luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255
6969+ return luminance > 0.5
7070+end
7171+7272+return M