comparison src/xterm.c @ 33456:d8d4ecfa24fd

(x_alloc_lighter_color): Use real brightness calculation. Just use FACTOR/2 instead of HIGHLIGHT_COLOR_DARK_BOOST. (HIGHLIGHT_COLOR_DARK_BOOST): Macro removed.
author Miles Bader <miles@gnu.org>
date Tue, 14 Nov 2000 01:44:33 +0000
parents 41fcaa0b864b
children 01f87b0ff56f
comparison
equal deleted inserted replaced
33455:f100c284e81e 33456:d8d4ecfa24fd
3487 #endif 3487 #endif
3488 return color.pixel; 3488 return color.pixel;
3489 } 3489 }
3490 3490
3491 3491
3492 3492 /* Brightness beyond which a color won't have its highlight brightness
3493 /* Constants used by x_alloc_lighter_color. */ 3493 boosted.
3494 3494
3495 /* How much to boost the brightness of 3d highlights for dark colors.
3496 Nominally, highlight colors for `3d' faces are calculated by 3495 Nominally, highlight colors for `3d' faces are calculated by
3497 brightening an object's color by a constant factor. If 3496 brightening an object's color by a constant scale factor, but this
3498 `highlight-color-dark-boost' is a floating point number between 0 and 3497 doesn't yield good results for dark colors, so for colors who's
3499 1, colors darker than `highlight-color-dark-boost-limit' have their 3498 brightness is less than this value (on a scale of 0-65535) have an
3500 highlight factor increased: a value of 0 means no increase at all, 3499 use an additional additive factor.
3501 and greater values yield correspondingly greater increases. */
3502 #define HIGHLIGHT_COLOR_DARK_BOOST 0.7
3503
3504 /* Brightness beyond which a color won't have its highlight brightness
3505 boosted. See HIGHLIGHT_COLOR_DARK_BOOST.
3506
3507 The `brightness' of a color, for this purpose, is defined to be the
3508 maximum of the color's red, green, or blue components, as returned by
3509 `color-values'.
3510 3500
3511 The value here is set so that the default menu-bar/mode-line color 3501 The value here is set so that the default menu-bar/mode-line color
3512 (grey75) will not have its highlights changed at all. */ 3502 (grey75) will not have its highlights changed at all. */
3513 #define HIGHLIGHT_COLOR_DARK_BOOST_LIMIT 48000 3503 #define HIGHLIGHT_COLOR_DARK_BOOST_LIMIT 48000
3514 3504
3541 xassert (factor >= 0); 3531 xassert (factor >= 0);
3542 new.red = min (0xffff, factor * color.red); 3532 new.red = min (0xffff, factor * color.red);
3543 new.green = min (0xffff, factor * color.green); 3533 new.green = min (0xffff, factor * color.green);
3544 new.blue = min (0xffff, factor * color.blue); 3534 new.blue = min (0xffff, factor * color.blue);
3545 3535
3546 /* Use the maximum component brightness as the overall brightness 3536 /* Calculate brightness of COLOR. */
3547 (this works quite well in practice). */ 3537 bright = (2 * color.red + 3 * color.green + color.blue) / 6;
3548 bright = color.red;
3549 if (color.green > bright)
3550 bright = color.green;
3551 if (color.blue > bright)
3552 bright = color.blue;
3553 3538
3554 /* We only boost colors that are darker than 3539 /* We only boost colors that are darker than
3555 HIGHLIGHT_COLOR_DARK_BOOST_LIMIT. */ 3540 HIGHLIGHT_COLOR_DARK_BOOST_LIMIT. */
3556 if (bright < HIGHLIGHT_COLOR_DARK_BOOST_LIMIT) 3541 if (bright < HIGHLIGHT_COLOR_DARK_BOOST_LIMIT)
3557 /* Make an additive adjustment to NEW, because it's dark enough so 3542 /* Make an additive adjustment to NEW, because it's dark enough so
3558 that scaling by FACTOR alone isn't enough. */ 3543 that scaling by FACTOR alone isn't enough. */
3559 { 3544 {
3560 /* How far below the limit this color is (0 - 1, 1 being darker). */ 3545 /* How far below the limit this color is (0 - 1, 1 being darker). */
3561 double dimness = 1 - (double)bright / HIGHLIGHT_COLOR_DARK_BOOST_LIMIT; 3546 double dimness = 1 - (double)bright / HIGHLIGHT_COLOR_DARK_BOOST_LIMIT;
3562 /* The additive adjustment. */ 3547 /* The additive adjustment. */
3563 int min_delta = delta * dimness * HIGHLIGHT_COLOR_DARK_BOOST; 3548 int min_delta = delta * dimness * factor / 2;
3564 3549
3565 if (factor < 1) 3550 if (factor < 1)
3566 { 3551 {
3567 min_delta /= 2;
3568 new.red = max (0, new.red - min_delta); 3552 new.red = max (0, new.red - min_delta);
3569 new.green = max (0, new.green - min_delta); 3553 new.green = max (0, new.green - min_delta);
3570 new.blue = max (0, new.blue - min_delta); 3554 new.blue = max (0, new.blue - min_delta);
3571 } 3555 }
3572 else 3556 else