Color
Comprehensive color and theme management system for the Lilia framework.
Overview
lia.color.register(name, color)
Purpose
Register a named color so string-based Color() calls can resolve it.
When Called
During client initialization or when adding palette entries at runtime.
Parameters
string name Identifier stored in lowercase.
table|Color color Table or Color with r, g, b, a fields.
Example Usage
lia.color.register("warning", Color(255, 140, 0))
local c = Color("warning")
lia.color.adjust(color, aOffset)
Purpose
Apply additive offsets to a color to quickly tint or shade it.
When Called
While building UI states (hover/pressed) or computing theme variants.
Parameters
Returns
Color Adjusted color.
Example Usage
local base = lia.color.getMainColor()
button:SetTextColor(lia.color.adjust(base, -40, -20, -60))
lia.color.darken(color, factor)
Purpose
Darken a color by a fractional factor.
When Called
Deriving hover/pressed backgrounds from a base accent color.
Parameters
Color color Base color to darken.
number factor optional Amount between 0-1; defaults to 0.1 and is clamped.
Returns
Color Darkened color.
Example Usage
local accent = lia.color.getMainColor()
local pressed = lia.color.darken(accent, 0.2)
lia.color.getCurrentTheme()
Purpose
Get the active theme id from config in lowercase.
When Called
Before looking up theme tables or theme-specific assets.
Returns
string Lowercased theme id (default "teal").
Example Usage
if lia.color.getCurrentTheme() == "dark" then
panel:SetDarkMode(true)
end
lia.color.getCurrentThemeName()
Purpose
Get the display name of the currently selected theme.
When Called
Showing UI labels or logs about the active theme.
Returns
string Theme name from config with original casing.
Example Usage
chat.AddText(Color(180, 220, 255), "Theme: ", lia.color.getCurrentThemeName())
lia.color.getMainColor()
Purpose
Fetch the main color from the current theme with sensible fallbacks.
When Called
Setting accent colors for buttons, bars, and highlights.
Returns
Color Main theme color, falling back to the default theme or teal.
Example Usage
local accent = lia.color.getMainColor()
button:SetTextColor(accent)
lia.color.applyTheme(themeName, useTransition)
Purpose
Apply a theme immediately or begin a smooth transition toward it, falling back to Teal/default palettes and firing OnThemeChanged after updates.
When Called
On config changes, theme selection menus, or client startup.
Parameters
string themeName optional Target theme id; defaults to the current config value.
boolean useTransition optional If true, blends colors over time instead of swapping instantly.
Example Usage
concommand.Add("lia_theme_preview", function(_, _, args)
lia.color.applyTheme(args[1] or "Teal", true)
end)
lia.color.isTransitionActive()
Purpose
Check whether a theme transition is currently blending.
When Called
To avoid overlapping transitions or to gate UI animations.
Returns
boolean True if a transition is active, otherwise false.
Example Usage
if lia.color.isTransitionActive() then return end
lia.color.applyTheme("Dark", true)
lia.color.testThemeTransition(themeName)
Purpose
Convenience wrapper to start a theme transition immediately.
When Called
From theme preview buttons to animate a swap.
Parameters
string themeName Target theme id.
Example Usage
vgui.Create("DButton").DoClick = function()
lia.color.testThemeTransition("Red")
end
lia.color.startThemeTransition(name)
Purpose
Begin blending from the current palette toward a target theme, falling back to Teal when missing and finishing by firing OnThemeChanged once applied.
When Called
Inside applyTheme when transitions are enabled or via previews.
Parameters
string name Theme id to blend toward.
Example Usage
lia.color.transition.speed = 1.5
lia.color.startThemeTransition("Ice")
lia.color.calculateNegativeColor(mainColor)
Purpose
Build a readable contrasting color (alpha 255) based on a main color.
When Called
Choosing text or negative colors for overlays and highlights.
Parameters
Color mainColor optional Defaults to the current theme main color when nil.
Returns
Color Contrasting color tuned for readability.
Example Usage
local negative = lia.color.calculateNegativeColor()
frame:SetTextColor(negative)
lia.color.returnMainAdjustedColors()
Purpose
Derive a suite of adjusted colors from the main theme color, including brightness-aware text and a calculated negative color.
When Called
Building consistent palettes for backgrounds, accents, and text.
Returns
table Contains background, sidebar, accent, text, hover, border, highlight, negative.
Example Usage
local palette = lia.color.returnMainAdjustedColors()
panel:SetBGColor(palette.background)
panel:SetTextColor(palette.text)
lia.color.lerp(frac, col1, col2)
Purpose
FrameTime-scaled color lerp helper.
When Called
Theme transitions or animated highlights needing smooth color changes.
Parameters
number frac Multiplier applied to FrameTime for lerp speed.
Color col1 Source color; defaults to white when nil.
Color col2 Target color; defaults to white when nil.
Returns
Color Interpolated color.
Example Usage
local blink = lia.color.lerp(6, Color(255, 0, 0), Color(255, 255, 255))
panel:SetBorderColor(blink)
lia.color.registerTheme(name, themeData)
Purpose
Register a theme table by name for later selection.
When Called
During initialization to expose custom palettes.
Parameters
string name Theme name/id; stored in lowercase.
table themeData Map of color keys to Color values or arrays.
Example Usage
lia.color.registerTheme("MyStudio", {
maincolor = Color(120, 200, 255),
background = Color(20, 24, 32),
text = Color(230, 240, 255)
})
lia.color.getAllThemes()
Purpose
Return a sorted list of available theme ids.
When Called
To populate config dropdowns or theme selection menus.
Returns
table Sorted array of theme ids.
Example Usage
local options = {}
for _, id in ipairs(lia.color.getAllThemes()) do
options[#options + 1] = id
end