| 216 | } |
| 217 | |
| 218 | export 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 | |
| 236 | export function mixColors(color1: HexColor, color2: HexColor, amount: number): HexColor { |
| 237 | const c1 = hexToOklch(color1) |