MCPcopy Create free account
hub / github.com/anomalyco/opencode / generateAlphaScale

Function generateAlphaScale

packages/ui/src/theme/color.ts:218–234  ·  view source on GitHub ↗
(scale: HexColor[], isDark: boolean)

Source from the content-addressed store, hash-verified

216}
217
218export function generateAlphaScale(scale: HexColor[], isDark: boolean): HexColor[] {
219 const alphas = isDark
220 ? [0.02, 0.04, 0.08, 0.12, 0.16, 0.2, 0.26, 0.36, 0.44, 0.52, 0.76, 0.96]
221 : [0.01, 0.03, 0.06, 0.09, 0.12, 0.15, 0.2, 0.28, 0.48, 0.56, 0.64, 0.88]
222
223 return scale.map((hex, i) => {
224 const { r, g, b } = hexToRgb(hex)
225 const a = alphas[i]
226
227 const bg = isDark ? 0 : 1
228 const blendedR = r * a + bg * (1 - a)
229 const blendedG = g * a + bg * (1 - a)
230 const blendedB = b * a + bg * (1 - a)
231
232 return rgbToHex(blendedR, blendedG, blendedB)
233 })
234}
235
236export function mixColors(color1: HexColor, color2: HexColor, amount: number): HexColor {
237 const c1 = hexToOklch(color1)

Callers

nothing calls this directly

Calls 2

rgbToHexFunction · 0.85
hexToRgbFunction · 0.70

Tested by

no test coverage detected