unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* color-grey-p and black?
@ 2005-09-26 20:04 Alex Schroeder
  2005-09-28 17:10 ` Richard M. Stallman
  0 siblings, 1 reply; 6+ messages in thread
From: Alex Schroeder @ 2005-09-26 20:04 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 216 bytes --]

I think color-gray-p should return t for shades of gray, white, and
black, as per doc string.  But it does not work for black...

(color-gray-p "white")
t
(color-gray-p "black")
nil
(color-gray-p "gray0")
nil

Alex.

[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 253 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: color-grey-p and black?
  2005-09-26 20:04 color-grey-p and black? Alex Schroeder
@ 2005-09-28 17:10 ` Richard M. Stallman
  2005-09-28 18:32   ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Richard M. Stallman @ 2005-09-28 17:10 UTC (permalink / raw)
  Cc: emacs-devel

Does this patch give good results?

*** xfaces.c	27 Sep 2005 17:58:18 -0400	1.336
--- xfaces.c	27 Sep 2005 23:09:16 -0400	
***************
*** 1477,1483 ****
  
  
  /* 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.  */
  
  static int
  face_color_gray_p (f, color_name)
--- 1477,1485 ----
  
  
  /* Return non-zero if COLOR_NAME is a shade of gray (or white or
!    black) on frame F.
! 
!    The criterion implemented here is not a terribly sophisticated one.  */
  
  static int
  face_color_gray_p (f, color_name)
***************
*** 1488,1499 ****
    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));
    else
      gray_p = 0;
  
--- 1490,1504 ----
    int gray_p;
  
    if (defined_color (f, color_name, &color, 0))
!     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;

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: color-grey-p and black?
  2005-09-28 17:10 ` Richard M. Stallman
@ 2005-09-28 18:32   ` Eli Zaretskii
  2005-09-29 14:10     ` Richard M. Stallman
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2005-09-28 18:32 UTC (permalink / raw)
  Cc: alex, emacs-devel

> From: "Richard M. Stallman" <rms@gnu.org>
> Date: Wed, 28 Sep 2005 13:10:46 -0400
> Cc: emacs-devel@gnu.org
> 
>     if (defined_color (f, color_name, &color, 0))
> !     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)));

Wouldn't it be better to simply replace "<" with "<=" in all 3
comparisons?  That seems to me like a less radical change.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: color-grey-p and black?
  2005-09-28 18:32   ` Eli Zaretskii
@ 2005-09-29 14:10     ` Richard M. Stallman
  2005-09-29 15:03       ` Daniel Brockman
  0 siblings, 1 reply; 6+ messages in thread
From: Richard M. Stallman @ 2005-09-29 14:10 UTC (permalink / raw)
  Cc: alex, emacs-devel

    Wouldn't it be better to simply replace "<" with "<=" in all 3
    comparisons?  That seems to me like a less radical change.

I don't know if it is better.  All the colors that fit the new clause
are very close to black, so it is right to say they are gray.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: color-grey-p and black?
  2005-09-29 14:10     ` Richard M. Stallman
@ 2005-09-29 15:03       ` Daniel Brockman
  2005-09-30 17:33         ` Richard M. Stallman
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Brockman @ 2005-09-29 15:03 UTC (permalink / raw)


"Richard M. Stallman" <rms@gnu.org> writes:

> All the colors that fit the new clause are very close to
> black, so it is right to say they are gray.

What about colors that are very close to white?

-- 
Daniel Brockman <daniel@brockman.se>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: color-grey-p and black?
  2005-09-29 15:03       ` Daniel Brockman
@ 2005-09-30 17:33         ` Richard M. Stallman
  0 siblings, 0 replies; 6+ messages in thread
From: Richard M. Stallman @ 2005-09-30 17:33 UTC (permalink / raw)
  Cc: emacs-devel

    What about colors that are very close to white?

They are accepted by the current criterion.

However, the current criterion was rather ad hoc.  I wrote it with no
expertise about such matters.  I suspect that someone who knows a lot
about color issues could suggest a better algorithm.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-09-30 17:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-26 20:04 color-grey-p and black? Alex Schroeder
2005-09-28 17:10 ` Richard M. Stallman
2005-09-28 18:32   ` Eli Zaretskii
2005-09-29 14:10     ` Richard M. Stallman
2005-09-29 15:03       ` Daniel Brockman
2005-09-30 17:33         ` Richard M. Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).