Fix gray tweaks: do not change level when tweaking

This commit is contained in:
Lea Verou
2025-03-24 12:37:56 -04:00
parent 827dd9f222
commit fa3b387bf1
2 changed files with 4 additions and 3 deletions

View File

@@ -1,11 +1,11 @@
import { tints } from '/assets/scripts/tweak/data.js';
export function generateGrays(colors, { grayColor, grayChroma }) {
export function generateGrays(colors, { grayColor, grayChroma, grayLevel }) {
let ret = {};
let undertoneScale = colors[grayColor];
// These will be the same, since scaling them won't change the relationship
ret.maxChromaTint = undertoneScale.maxChromaTint;
ret.maxChromaTint = grayLevel ?? undertoneScale.maxChromaTint;
Object.defineProperty(ret, 'core', {
enumerable: false,
get() {

View File

@@ -28,7 +28,8 @@ export function tweakPalette(baseColors, tweaks, tweaked) {
if (tweaked.grayChroma || tweaked.grayColor) {
let grayColor = tweaks.grayColor ?? this.originalGrayColor;
let grayChroma = this.computedGrayChroma;
ret.gray = generateGrays(baseColors, { grayColor, grayChroma });
let grayLevel = baseColors.gray?.maxChromaTint;
ret.gray = generateGrays(baseColors, { grayColor, grayChroma, grayLevel });
} else {
ret.gray = originalScale;
}