aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader <[email protected]>2000-11-13 15:47:32 +0000
committerMiles Bader <[email protected]>2000-11-13 15:47:32 +0000
commit6d8b0acd4a34bbeb0c42621a6408aa89c833f6e0 (patch)
tree0e8df8118ce42dec16ab5276b9c419a87d1c6334 /src
parent1695ca2b1595c7bae5ac565a034196797085eb41 (diff)
(x_alloc_lighter_color): Include an additive component too for dark
colors, because FACTOR isn't enough. (HIGHLIGHT_COLOR_DARK_BOOST, HIGHLIGHT_COLOR_DARK_BOOST_LIMIT): New macros.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/src/xterm.c b/src/xterm.c
index a49cc147f2..43294d267c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3489,6 +3489,30 @@ 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.
+
+ 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'.
+
+ The value here is set so that the default menu-bar/mode-line color
+ (grey75) will not have its highlights changed at all. */
+#define HIGHLIGHT_COLOR_DARK_BOOST_LIMIT 48000
+
+
/* Allocate a color which is lighter or darker than *PIXEL by FACTOR
or DELTA. Try a color with RGB values multiplied by FACTOR first.
If this produces the same color as PIXEL, try a color where all RGB
@@ -3506,6 +3530,7 @@ x_alloc_lighter_color (f, display, cmap, pixel, factor, delta)
int delta;
{
XColor color, new;
+ long bright;
int success_p;
/* Get RGB color values. */
@@ -3518,6 +3543,40 @@ 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;
+
+ /* We only boost colors that are darker than
+ HIGHLIGHT_COLOR_DARK_BOOST_LIMIT. */
+ if (bright < HIGHLIGHT_COLOR_DARK_BOOST_LIMIT)
+ /* Make an additive adjustment to NEW, because it's dark enough so
+ that scaling by FACTOR alone isn't enough. */
+ {
+ /* 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;
+
+ 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);
+ }
+ else
+ {
+ new.red = min (0xffff, min_delta + new.red);
+ new.green = min (0xffff, min_delta + new.green);
+ new.blue = min (0xffff, min_delta + new.blue);
+ }
+ }
+
/* Try to allocate the color. */
success_p = x_alloc_nearest_color (f, cmap, &new);
if (success_p)
@@ -13891,4 +13950,3 @@ wide as that tab on the display.");
}
#endif /* not HAVE_X_WINDOWS */
-