优化默认背景颜色计算逻辑
This commit is contained in:
parent
dc36b4c706
commit
73cad2900d
@ -1008,7 +1008,7 @@ const resetUpload = () => {
|
||||
}
|
||||
}
|
||||
|
||||
// Convert RGB to light pastel color using OKLCH
|
||||
// Convert RGB to light pastel color using OKLCH (adaptive approach)
|
||||
const rgbToLightPastel = (r: number, g: number, b: number): string => {
|
||||
// Convert RGB to hex first
|
||||
const rHex = Math.round(r).toString(16).padStart(2, '0')
|
||||
@ -1019,9 +1019,23 @@ const rgbToLightPastel = (r: number, g: number, b: number): string => {
|
||||
// Convert to OKLCH
|
||||
const { l, c, h } = hexToOklch(hexColor)
|
||||
|
||||
// Create light pastel version: high lightness (0.92), reduced chroma
|
||||
const pastelL = 0.92
|
||||
const pastelC = Math.min(c, 0.08) // Reduce chroma for pastel effect
|
||||
// Adaptive lightness: ensure it's in the light range (0.85-0.95)
|
||||
// If original is already light, keep it; if dark, lighten it
|
||||
let pastelL: number
|
||||
if (l >= 0.85) {
|
||||
// Already light enough, use original
|
||||
pastelL = l
|
||||
} else if (l >= 0.7) {
|
||||
// Medium brightness, lighten moderately
|
||||
pastelL = 0.88
|
||||
} else {
|
||||
// Dark color, lighten significantly
|
||||
pastelL = 0.92
|
||||
}
|
||||
|
||||
// Adaptive chroma: maintain color character while keeping it soft
|
||||
// Reduce chroma but keep some saturation for color recognition
|
||||
const pastelC = Math.min(c * 0.5, 0.12) // Keep up to 50% chroma, max 0.12
|
||||
|
||||
return oklchToHex(pastelL, pastelC, h)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user