getForegroundFromBackground() — ui Function Reference
Architecture documentation for the getForegroundFromBackground() function in colors.ts from the ui codebase.
Entity Profile
Dependency Diagram
graph TD 6b606878_0d79_8de6_e626_663ec772f427["getForegroundFromBackground()"] 955bc1fa_55c7_f589_a22c_805b535067fd["colors.ts"] 6b606878_0d79_8de6_e626_663ec772f427 -->|defined in| 955bc1fa_55c7_f589_a22c_805b535067fd 99de8c20_3740_56dc_5dbd_6723bac57629["getColors()"] 99de8c20_3740_56dc_5dbd_6723bac57629 -->|calls| 6b606878_0d79_8de6_e626_663ec772f427 style 6b606878_0d79_8de6_e626_663ec772f427 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
deprecated/www/lib/colors.ts lines 79–93
function getForegroundFromBackground(rgb: string) {
const [r, g, b] = rgb.split(" ").map(Number)
function toLinear(number: number): number {
const base = number / 255
return base <= 0.04045
? base / 12.92
: Math.pow((base + 0.055) / 1.055, 2.4)
}
const luminance =
0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b)
return luminance > 0.179 ? "#000" : "#fff"
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does getForegroundFromBackground() do?
getForegroundFromBackground() is a function in the ui codebase, defined in deprecated/www/lib/colors.ts.
Where is getForegroundFromBackground() defined?
getForegroundFromBackground() is defined in deprecated/www/lib/colors.ts at line 79.
What calls getForegroundFromBackground()?
getForegroundFromBackground() is called by 1 function(s): getColors.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free