]> git.eshelyaron.com Git - emacs.git/commitdiff
(x_alloc_lighter_color): Use real brightness calculation.
authorMiles Bader <miles@gnu.org>
Tue, 14 Nov 2000 01:45:45 +0000 (01:45 +0000)
committerMiles Bader <miles@gnu.org>
Tue, 14 Nov 2000 01:45:45 +0000 (01:45 +0000)
  Just use FACTOR/2 instead of HIGHLIGHT_COLOR_DARK_BOOST.
(HIGHLIGHT_COLOR_DARK_BOOST): Macro removed.

src/ChangeLog
src/xterm.c

index 86362c4086bfcf7675e2577938be039e5ef84096..31a116a8fe64a201c66c4467883a6cde2c6a54f9 100644 (file)
@@ -1,3 +1,9 @@
+2000-11-14  Miles Bader  <miles@lsi.nec.co.jp>
+
+       * xterm.c (x_alloc_lighter_color): Use real brightness calculation.
+       Just use FACTOR/2 instead of HIGHLIGHT_COLOR_DARK_BOOST.
+       (HIGHLIGHT_COLOR_DARK_BOOST): Macro removed.
+
 2000-11-14  Miles Bader  <miles@gnu.org>
 
        * xterm.c (x_alloc_lighter_color): Include an additive component
index 43294d267c5b08194d40e5ccd6b6324b997e8b85..ec7f6b16d028d3e358262f257dc2a2db916b52f4 100644 (file)
@@ -3489,24 +3489,14 @@ x_copy_dpy_color (dpy, cmap, pixel)
 }
 
 
-
-/* Constants used by x_alloc_lighter_color.  */
-
-/* How much to boost the brightness of 3d highlights for dark colors.
-   Nominally, highlight colors for `3d' faces are calculated by
-   brightening an object's color by a constant factor.  If
-   `highlight-color-dark-boost' is a floating point number between 0 and
-   1, colors darker than `highlight-color-dark-boost-limit' have their
-   highlight factor increased: a value of 0 means no increase at all,
-   and greater values yield correspondingly greater increases.  */
-#define HIGHLIGHT_COLOR_DARK_BOOST 0.7
-
 /* Brightness beyond which a color won't have its highlight brightness
-   boosted.  See HIGHLIGHT_COLOR_DARK_BOOST.
+   boosted.
 
-   The `brightness' of a color, for this purpose, is defined to be the
-   maximum of the color's red, green, or blue components, as returned by
-   `color-values'.
+   Nominally, highlight colors for `3d' faces are calculated by
+   brightening an object's color by a constant scale factor, but this
+   doesn't yield good results for dark colors, so for colors who's
+   brightness is less than this value (on a scale of 0-65535) have an
+   use an additional additive factor.
 
    The value here is set so that the default menu-bar/mode-line color
    (grey75) will not have its highlights changed at all.  */
@@ -3543,13 +3533,8 @@ x_alloc_lighter_color (f, display, cmap, pixel, factor, delta)
   new.green = min (0xffff, factor * color.green);
   new.blue = min (0xffff, factor * color.blue);
 
-  /* Use the maximum component brightness as the overall brightness
-     (this works quite well in practice).  */
-  bright = color.red;
-  if (color.green > bright)
-    bright = color.green;
-  if (color.blue > bright)
-    bright = color.blue;
+  /* Calculate brightness of COLOR.  */
+  bright = (2 * color.red + 3 * color.green + color.blue) / 6;
 
   /* We only boost colors that are darker than
      HIGHLIGHT_COLOR_DARK_BOOST_LIMIT.  */
@@ -3560,11 +3545,10 @@ x_alloc_lighter_color (f, display, cmap, pixel, factor, delta)
       /* How far below the limit this color is (0 - 1, 1 being darker).  */
       double dimness = 1 - (double)bright / HIGHLIGHT_COLOR_DARK_BOOST_LIMIT;
       /* The additive adjustment.  */
-      int min_delta = delta * dimness * HIGHLIGHT_COLOR_DARK_BOOST;
+      int min_delta = delta * dimness * factor / 2;
 
       if (factor < 1)
        {
-         min_delta /= 2;
          new.red =   max (0, new.red -   min_delta);
          new.green = max (0, new.green - min_delta);
          new.blue =  max (0, new.blue -  min_delta);