unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Richard M. Stallman" <rms@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: color-grey-p and black?
Date: Wed, 28 Sep 2005 13:10:46 -0400	[thread overview]
Message-ID: <E1EKfSA-0001vI-80@fencepost.gnu.org> (raw)
In-Reply-To: <4338545C.9080003@gnu.org> (message from Alex Schroeder on Mon, 26 Sep 2005 22:04:44 +0200)

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;

  reply	other threads:[~2005-09-28 17:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-26 20:04 color-grey-p and black? Alex Schroeder
2005-09-28 17:10 ` Richard M. Stallman [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1EKfSA-0001vI-80@fencepost.gnu.org \
    --to=rms@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).