(seed: HexColor, isDark: boolean)
| 131 | } |
| 132 | |
| 133 | export function generateScale(seed: HexColor, isDark: boolean): HexColor[] { |
| 134 | const base = hexToOklch(seed) |
| 135 | const scale: HexColor[] = [] |
| 136 | |
| 137 | const lightSteps = isDark |
| 138 | ? [ |
| 139 | 0.118, |
| 140 | 0.138, |
| 141 | 0.167, |
| 142 | 0.202, |
| 143 | 0.246, |
| 144 | 0.304, |
| 145 | 0.378, |
| 146 | 0.468, |
| 147 | clamp(base.l * 0.825, 0.53, 0.705), |
| 148 | clamp(base.l * 0.89, 0.61, 0.79), |
| 149 | clamp(base.l + 0.033, 0.868, 0.943), |
| 150 | 0.984, |
| 151 | ] |
| 152 | : [0.993, 0.983, 0.962, 0.936, 0.906, 0.866, 0.811, 0.74, base.l, Math.max(0, base.l - 0.036), 0.49, 0.27] |
| 153 | |
| 154 | const chromaMultipliers = isDark |
| 155 | ? [0.52, 0.68, 0.86, 1.02, 1.14, 1.24, 1.36, 1.48, 1.56, 1.64, 1.62, 1.15] |
| 156 | : [0.12, 0.24, 0.46, 0.68, 0.84, 0.98, 1.08, 1.16, 1.22, 1.26, 1.18, 0.98] |
| 157 | |
| 158 | for (let i = 0; i < 12; i++) { |
| 159 | scale.push( |
| 160 | oklchToHex({ |
| 161 | l: lightSteps[i], |
| 162 | c: base.c * chromaMultipliers[i], |
| 163 | h: base.h, |
| 164 | }), |
| 165 | ) |
| 166 | } |
| 167 | |
| 168 | return scale |
| 169 | } |
| 170 | |
| 171 | export function generateNeutralScale(seed: HexColor, isDark: boolean, ink?: HexColor): HexColor[] { |
| 172 | if (ink) { |
no test coverage detected