emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r102509: shr-color.el (shr-color-visi


From: Katsumi Yamaoka
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r102509: shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Date: Thu, 25 Nov 2010 07:46:51 +0000
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 102509
author: Lars Magne Ingebrigtsen <address@hidden>
committer: Katsumi Yamaoka <address@hidden>
branch nick: trunk
timestamp: Thu 2010-11-25 07:46:51 +0000
message:
  shr-color.el (shr-color-visible): Don't bug out if the colour names don't 
exist.
modified:
  lisp/gnus/ChangeLog
  lisp/gnus/shr-color.el
=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog       2010-11-25 05:09:25 +0000
+++ b/lisp/gnus/ChangeLog       2010-11-25 07:46:51 +0000
@@ -1,3 +1,8 @@
+2010-11-25  Lars Magne Ingebrigtsen  <address@hidden>
+
+       * shr-color.el (shr-color-visible): Don't bug out if the colour names
+       don't exist.
+
 2010-11-25  Katsumi Yamaoka  <address@hidden>
 
        * mml.el (mml-preview): Make sure to bind gnus-displaying-mime to nil,

=== modified file 'lisp/gnus/shr-color.el'
--- a/lisp/gnus/shr-color.el    2010-11-24 22:54:47 +0000
+++ b/lisp/gnus/shr-color.el    2010-11-25 07:46:51 +0000
@@ -324,29 +324,36 @@
 new background color will not be computed. Only the foreground
 color will be adapted to be visible on BG."
   ;; Convert fg and bg to CIE Lab
-  (let* ((fg-lab (apply 'rgb->lab (rgb->normalize fg)))
-         (bg-lab (apply 'rgb->lab (rgb->normalize bg)))
-         ;; Compute color distance using CIE DE 2000
-         (fg-bg-distance (color-lab-ciede2000 fg-lab bg-lab))
-         ;; Compute luminance distance (substract L component)
-         (luminance-distance (abs (- (car fg-lab) (car bg-lab)))))
-    (if (and (>= fg-bg-distance shr-color-visible-distance-min)
-             (>= luminance-distance shr-color-visible-luminance-min))
-        (list bg fg)
-      ;; Not visible, try to change luminance to make them visible
-      (let ((Ls (set-minimum-interval (car bg-lab) (car fg-lab) 0 100
-                                      shr-color-visible-luminance-min
-                                      fixed-background)))
-        (unless fixed-background
-          (setcar bg-lab (car Ls)))
-        (setcar fg-lab (cadr Ls))
-        (list
-         (if fixed-background
-             bg
-           (apply 'format "#%02x%02x%02x"
-                  (mapcar (lambda (x) (* (max (min 1 x) 0) 255)) (apply 
'lab->rgb bg-lab))))
-         (apply 'format "#%02x%02x%02x"
-                (mapcar (lambda (x) (* (max (min 1 x) 0) 255)) (apply 
'lab->rgb fg-lab))))))))
+  (let ((fg-norm (rgb->normalize fg))
+       (bg-norm (rgb->normalize bg)))
+    (if (or (null fg-norm)
+           (null bg-norm))
+       (list bg fg)
+      (let* ((fg-lab (apply 'rgb->lab fg-norm))
+            (bg-lab (apply 'rgb->lab bg-norm))
+            ;; Compute color distance using CIE DE 2000
+            (fg-bg-distance (color-lab-ciede2000 fg-lab bg-lab))
+            ;; Compute luminance distance (substract L component)
+            (luminance-distance (abs (- (car fg-lab) (car bg-lab)))))
+       (if (and (>= fg-bg-distance shr-color-visible-distance-min)
+                (>= luminance-distance shr-color-visible-luminance-min))
+           (list bg fg)
+         ;; Not visible, try to change luminance to make them visible
+         (let ((Ls (set-minimum-interval (car bg-lab) (car fg-lab) 0 100
+                                         shr-color-visible-luminance-min
+                                         fixed-background)))
+           (unless fixed-background
+             (setcar bg-lab (car Ls)))
+           (setcar fg-lab (cadr Ls))
+           (list
+            (if fixed-background
+                bg
+              (apply 'format "#%02x%02x%02x"
+                     (mapcar (lambda (x) (* (max (min 1 x) 0) 255))
+                             (apply 'lab->rgb bg-lab))))
+            (apply 'format "#%02x%02x%02x"
+                   (mapcar (lambda (x) (* (max (min 1 x) 0) 255))
+                           (apply 'lab->rgb fg-lab))))))))))
 
 (provide 'shr-color)
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]