From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Face color changes Date: Sun, 26 Dec 2004 21:57:38 +0200 Organization: JURTA Message-ID: <87fz1srfmt.fsf@jurta.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1104091614 4642 80.91.229.6 (26 Dec 2004 20:06:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 26 Dec 2004 20:06:54 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 26 21:06:48 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CiefA-00037p-00 for ; Sun, 26 Dec 2004 21:06:48 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Ciepv-0000RU-FR for ged-emacs-devel@m.gmane.org; Sun, 26 Dec 2004 15:17:55 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CiepP-0000QQ-Jx for emacs-devel@gnu.org; Sun, 26 Dec 2004 15:17:23 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CiepN-0000PP-Nc for emacs-devel@gnu.org; Sun, 26 Dec 2004 15:17:22 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CiepN-0000P1-Ff for emacs-devel@gnu.org; Sun, 26 Dec 2004 15:17:21 -0500 Original-Received: from [194.126.101.98] (helo=MXR-3.estpak.ee) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CiedU-0004uT-67 for emacs-devel@gnu.org; Sun, 26 Dec 2004 15:05:04 -0500 Original-Received: from mail.neti.ee (80-235-36-76-dsl.mus.estpak.ee [80.235.36.76]) by MXR-3.estpak.ee (Postfix) with ESMTP id DC62BFC790 for ; Sun, 26 Dec 2004 22:04:59 +0200 (EET) Original-To: emacs-devel@gnu.org User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-Virus-Scanned: by amavisd-new-2.2.1 (20041222) (Debian) at neti.ee X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:31417 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:31417 I noticed that some face colors are bad choices. The worst example is "RosyBrown" used for font-lock-string-face on light backgrounds. It has high intensity which corresponds to light colors. No wonder that this color is hardly visible on light backgrounds. I got the formula from x_alloc_nearest_color_1 to calculate a dark color nearest to "rosybrown". The code is below: (let* ((frame (selected-frame)) (color-values (mapcar (lambda (v) (lsh v -8)) (x-color-values "rosybrown" frame))) (c-r (nth 0 color-values)) (c-g (nth 1 color-values)) (c-b (nth 2 color-values))) (list-colors-display (delq nil (mapcar (lambda (c) (and (eq (color-mode (cadr c)) 'dark) (cadr c))) (sort (mapcar (lambda (c) (let* ((c-values (mapcar (lambda (v) (lsh v -8)) (x-color-values (car c) frame))) (d-r (- c-r (nth 0 c-values))) (d-g (- c-g (nth 1 c-values))) (d-b (- c-b (nth 2 c-values)))) (list (+ (* d-r d-r) (* d-g d-g) (* d-b d-b)) (car c)))) (list-colors-duplicates)) (lambda (a b) (< (car a) (car b)))))) "*Colors-Nearest*")) (defun color-mode (bg-color) (let ((frame (selected-frame))) (if (let ((bg-color-values (x-color-values bg-color frame)) (white-values (x-color-values "white" frame))) (>= (+ (* (nth 0 bg-color-values) 0.30) (* (nth 1 bg-color-values) 0.59) (* (nth 2 bg-color-values) 0.11)) (* (+ (* (nth 0 white-values) 0.30) (* (nth 1 white-values) 0.59) (* (nth 2 white-values) 0.11)) .5))) 'light 'dark))) It suggests to replace "rosybrown" by "plum4" or "PaleVioletRed4", and "orchid" (for font-lock-builtin-face) by "MediumOrchid3" or "DarkOrchid3". If this is correct, other face colors could be improved as well to match their background mode (i.e. to use light colors on dark backgrounds, and dark colors on light backgrounds). -- Juri Linkov http://www.jurta.org/emacs/