fix(colors): Correct perceptual correction threshold
Changed threshold from 0.45 to 0.15 so that: - Blue (~0.07 luminance) gets boost to avoid "goes to black" effect - Red (~0.21 luminance) is NOT affected (already darkens nicely) This fixes the issue where red panels became too saturated. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
b63cf44d88
commit
0a2f02a0a4
1 changed files with 16 additions and 15 deletions
|
|
@ -42,9 +42,10 @@ pub fn isFancy() bool {
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
/// Enable perceptual correction for panel colors.
|
/// Enable perceptual correction for panel colors.
|
||||||
/// NOTE: Desactivado por defecto - la lógica actual boostea el rojo cuando
|
/// When enabled, colors with VERY low perceived luminance (e.g., blue ~0.07)
|
||||||
/// debería compensar el azul. Requiere revisión del algoritmo.
|
/// get a boost to avoid going to black when darkened.
|
||||||
var perceptual_correction_enabled: bool = false;
|
/// Colors like red (~0.21) are NOT affected as they darken well naturally.
|
||||||
|
var perceptual_correction_enabled: bool = true;
|
||||||
|
|
||||||
/// Get whether perceptual correction is enabled
|
/// Get whether perceptual correction is enabled
|
||||||
pub fn isPerceptualCorrectionEnabled() bool {
|
pub fn isPerceptualCorrectionEnabled() bool {
|
||||||
|
|
@ -1076,15 +1077,15 @@ fn deriveDarkPalette(base: Color) PanelColorScheme {
|
||||||
const gray = Color.rgb(128, 128, 128);
|
const gray = Color.rgb(128, 128, 128);
|
||||||
const dark_border = Color.rgb(60, 60, 65);
|
const dark_border = Color.rgb(60, 60, 65);
|
||||||
|
|
||||||
// Perceptual correction: boost low-luminance colors to match visual contrast
|
// Perceptual correction: only for colors with VERY low luminance (like pure blue ~0.07)
|
||||||
// Reference: laravel_blue has luminance ~0.48, we use 0.45 as target
|
// Red (~0.21) is above threshold and won't be affected
|
||||||
const base_lum = base.perceptualLuminance();
|
const base_lum = base.perceptualLuminance();
|
||||||
const target_lum: f32 = 0.45; // Reference luminance (approximately blue)
|
const threshold: f32 = 0.15; // Only affect colors below this (blue=0.07, red=0.21)
|
||||||
|
|
||||||
// Calculate correction factor: if luminance is lower than target, reduce blend %
|
// Calculate correction factor: if luminance is VERY low, reduce blend %
|
||||||
// This makes more of the base color visible, compensating for lower brightness
|
// This makes more of the base color visible, preventing "goes to black" effect
|
||||||
const correction: f32 = if (perceptual_correction_enabled and base_lum < target_lum)
|
const correction: f32 = if (perceptual_correction_enabled and base_lum < threshold)
|
||||||
@max(0.7, base_lum / target_lum) // Cap at 0.7 to avoid excessive boost
|
@max(0.75, base_lum / threshold) // Subtle boost for very dark colors
|
||||||
else
|
else
|
||||||
1.0;
|
1.0;
|
||||||
|
|
||||||
|
|
@ -1130,13 +1131,13 @@ fn deriveLightPalette(base: Color) PanelColorScheme {
|
||||||
const gray = Color.rgb(128, 128, 128);
|
const gray = Color.rgb(128, 128, 128);
|
||||||
const light_border = Color.rgb(220, 220, 225);
|
const light_border = Color.rgb(220, 220, 225);
|
||||||
|
|
||||||
// Perceptual correction: boost low-luminance colors to match visual contrast
|
// Perceptual correction: only for colors with VERY low luminance (like pure blue ~0.07)
|
||||||
// In light mode, lower blend % means more base color visible
|
// Red (~0.21) is above threshold and won't be affected
|
||||||
const base_lum = base.perceptualLuminance();
|
const base_lum = base.perceptualLuminance();
|
||||||
const target_lum: f32 = 0.45;
|
const threshold: f32 = 0.15; // Only affect colors below this (blue=0.07, red=0.21)
|
||||||
|
|
||||||
const correction: f32 = if (perceptual_correction_enabled and base_lum < target_lum)
|
const correction: f32 = if (perceptual_correction_enabled and base_lum < threshold)
|
||||||
@max(0.7, base_lum / target_lum)
|
@max(0.75, base_lum / threshold) // Subtle boost for very dark colors
|
||||||
else
|
else
|
||||||
1.0;
|
1.0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue