# HG changeset patch # User Richard M. Stallman # Date 1128223736 0 # Node ID d9e5cd5bce05a8abde2d3a6084a95b8779067caf # Parent 6e229fd948153c0889176b2bea50189d76863990 (face_color_gray_p): Colors close to black count as gray. diff -r 6e229fd94815 -r d9e5cd5bce05 src/xfaces.c --- a/src/xfaces.c Sun Oct 02 03:11:03 2005 +0000 +++ b/src/xfaces.c Sun Oct 02 03:28:56 2005 +0000 @@ -1477,7 +1477,9 @@ /* 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 @@ 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;