From 71433d39f54a26dbe9b5ff6c87e66e8cba8b2c10 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Sun, 2 Oct 2005 03:28:56 +0000 Subject: [PATCH] (face_color_gray_p): Colors close to black count as gray. --- src/xfaces.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/xfaces.c b/src/xfaces.c index aa32c84b297..49ba6d334ec 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -1477,7 +1477,9 @@ tty_color_name (f, idx) /* Return non-zero if COLOR_NAME is a shade of gray (or white or - black) on frame F. The algorithm is taken from 20.2 faces.el. */ + black) on frame F. + + The criterion implemented here is not a terribly sophisticated one. */ static int face_color_gray_p (f, color_name) @@ -1488,12 +1490,15 @@ face_color_gray_p (f, color_name) int gray_p; if (defined_color (f, color_name, &color, 0)) - gray_p = ((abs (color.red - color.green) - < max (color.red, color.green) / 20) - && (abs (color.green - color.blue) - < max (color.green, color.blue) / 20) - && (abs (color.blue - color.red) - < max (color.blue, color.red) / 20)); + gray_p = (/* Any color sufficiently close to black counts as grey. */ + (color.red < 5000 && color.green < 5000 && color.blue < 5000) + || + ((abs (color.red - color.green) + < max (color.red, color.green) / 20) + && (abs (color.green - color.blue) + < max (color.green, color.blue) / 20) + && (abs (color.blue - color.red) + < max (color.blue, color.red) / 20))); else gray_p = 0; -- 2.39.5