1477 |
|
|
1478 |
|
|
1479 |
/* Return non-zero if COLOR_NAME is a shade of gray (or white or |
/* Return non-zero if COLOR_NAME is a shade of gray (or white or |
1480 |
black) on frame F. The algorithm is taken from 20.2 faces.el. */ |
black) on frame F. |
1481 |
|
|
1482 |
|
The criterion implemented here is not a terribly sophisticated one. */ |
1483 |
|
|
1484 |
static int |
static int |
1485 |
face_color_gray_p (f, color_name) |
face_color_gray_p (f, color_name) |
1490 |
int gray_p; |
int gray_p; |
1491 |
|
|
1492 |
if (defined_color (f, color_name, &color, 0)) |
if (defined_color (f, color_name, &color, 0)) |
1493 |
gray_p = ((abs (color.red - color.green) |
gray_p = (/* Any color sufficiently close to black counts as grey. */ |
1494 |
< max (color.red, color.green) / 20) |
(color.red < 5000 && color.green < 5000 && color.blue < 5000) |
1495 |
&& (abs (color.green - color.blue) |
|| |
1496 |
< max (color.green, color.blue) / 20) |
((abs (color.red - color.green) |
1497 |
&& (abs (color.blue - color.red) |
< max (color.red, color.green) / 20) |
1498 |
< max (color.blue, color.red) / 20)); |
&& (abs (color.green - color.blue) |
1499 |
|
< max (color.green, color.blue) / 20) |
1500 |
|
&& (abs (color.blue - color.red) |
1501 |
|
< max (color.blue, color.red) / 20))); |
1502 |
else |
else |
1503 |
gray_p = 0; |
gray_p = 0; |
1504 |
|
|