Color¶
Color and theme helpers for Lilia UI colors, named color lookup, theme registration, active theme application, and clientside theme transitions.
Overview
lia.color.register(name, color)View Source
Purpose
Registers a named color value in `lia.color.stored` using a lowercase key.
Realm
Client
Parameters
string name The color name to register.
Color|table color The color value to store for the provided name.
Example Usage
lia.color.register("warning", Color(255, 180, 0))
lia.color.register("panel_shadow", Color(0, 0, 0, 120))
lia.color.adjust(color, rOffset, gOffset, bOffset, aOffset)View Source
Purpose
Returns a new color with channel offsets applied and clamped between 0 and 255.
Realm
Client
Parameters
Color color The base color to adjust.
number rOffset The amount to add to the red channel.
number gOffset The amount to add to the green channel.
number bOffset The amount to add to the blue channel.
number aOffset optional Optional amount to add to the alpha channel.
Returns
Color The adjusted color.
Example Usage
local hoverColor = lia.color.adjust(lia.color.getMainColor(), 20, 20, 20)
local transparentColor = lia.color.adjust(Color(80, 120, 180, 255), 0, 0, 0, -80)
lia.color.darken(color, factor)View Source
Purpose
Returns a darker copy of the provided color.
Realm
Client
Parameters
Color color The color to darken.
number factor optional Optional darkening strength from 0 to 1. Defaults to 0.1.
Returns
Color The darkened color.
Example Usage
local shadow = lia.color.darken(lia.color.getMainColor(), 0.35)
lia.color.getCurrentTheme()View Source
Purpose
Gets the configured theme identifier in lowercase form.
Realm
Client
Returns
string The lowercase configured theme identifier.
Example Usage
local themeID = lia.color.getCurrentTheme()
lia.color.getCurrentThemeName()View Source
Purpose
Gets the configured theme value exactly as stored in config.
Realm
Client
Returns
string The configured theme name or `Teal` when no value is configured.
Example Usage
local themeName = lia.color.getCurrentThemeName()
lia.color.getMainColor()View Source
Purpose
Gets the main color for the currently configured theme.
Realm
Client
Returns
Color The current theme main color, the teal theme main color, or the built-in fallback color.
Example Usage
surface.SetDrawColor(lia.color.getMainColor())
lia.color.applyTheme(themeName, useTransition)View Source
Purpose
Applies a theme by name, optionally using a clientside transition, and runs `OnThemeChanged`.
Realm
Client
Parameters
string themeName optional Optional theme name to apply. Uses the configured theme when omitted.
boolean useTransition optional Whether to start a theme transition instead of applying the theme directly.
Example Usage
lia.color.applyTheme("dark", false)
lia.color.applyTheme("blue", true)
lia.color.isTransitionActive()View Source
Purpose
Checks whether a theme transition is currently active.
Realm
Client
Returns
boolean True when a theme transition is active, otherwise false.
Example Usage
if lia.color.isTransitionActive() then return end
lia.color.testThemeTransition(themeName)View Source
Purpose
Starts a transition to the provided theme name through `lia.color.applyTheme`.
Realm
Client
Parameters
string themeName The theme name to transition to.
Example Usage
lia.color.testThemeTransition("purple")
lia.color.startThemeTransition(name)View Source
Purpose
Starts an animated transition from stored color values toward a target theme.
Realm
Client
Parameters
string name The target theme name. Falls back to `Teal` when the requested theme is unavailable.
Example Usage
lia.color.startThemeTransition("coffee")
lia.color.isColor(v)View Source
Purpose
Checks whether a value is a color table with numeric red, green, blue, and alpha channels.
Realm
Client
Parameters
any v The value to check.
Returns
boolean True when the value has numeric `r`, `g`, `b`, and `a` fields, otherwise false.
Example Usage
if lia.color.isColor(lia.color.getMainColor()) then
surface.SetDrawColor(lia.color.getMainColor())
end
lia.color.calculateNegativeColor(mainColor)View Source
Purpose
Calculates a contrasting negative accent color from the provided main color.
Realm
Client
Parameters
Color mainColor optional Optional base color. Uses the current theme main color when omitted.
Returns
Color The calculated negative accent color.
Example Usage
local negative = lia.color.calculateNegativeColor(lia.color.getMainColor())
lia.color.returnMainAdjustedColors()View Source
Purpose
Builds a derived color palette from the current theme main color.
Realm
Client
Returns
table A table containing background, sidebar, accent, text, hover, border, highlight, and negative colors.
Example Usage
local colors = lia.color.returnMainAdjustedColors()
surface.SetDrawColor(colors.background)
lia.color.lerp(frac, col1, col2)View Source
Purpose
Interpolates from one color toward another using `FrameTime()` multiplied by the provided fraction.
Realm
Client
Parameters
number frac The interpolation multiplier applied to `FrameTime()`.
Color col1 optional The starting color. Missing channels default to 255.
Color col2 optional The target color. Missing channels default to 255.
Returns
Color The interpolated color.
Example Usage
local blended = lia.color.lerp(8, Color(0, 0, 0), lia.color.getMainColor())
lia.color.registerTheme(name, themeData)View Source
Purpose
Registers a theme table by lowercase theme identifier.
Realm
Shared
Parameters
string name The display name or identifier for the theme.
table themeData The theme color data to store.
Example Usage
lia.color.registerTheme("Amber", {
maincolor = Color(220, 150, 60),
background = Color(30, 24, 18),
text = Color(255, 238, 210)
})
lia.color.getAllThemes()View Source
Purpose
Returns every registered theme identifier sorted alphabetically.
Realm
Shared
Returns
table A sorted array of registered lowercase theme identifiers.
Example Usage
for _, themeID in ipairs(lia.color.getAllThemes()) do
print(themeID)
end
Hooks
Library-specific hooks documented for this library.