diff options
| author | Lars Magne Ingebrigtsen | 2010-11-25 07:46:51 +0000 |
|---|---|---|
| committer | Katsumi Yamaoka | 2010-11-25 07:46:51 +0000 |
| commit | fded65c75a6124a95e1b0d05a34a704abaae5281 (patch) | |
| tree | dea5687ab9e8a0f586f78536aebee38ac86ab436 | |
| parent | e4f123a4029887f212f183aac27dc616687236eb (diff) | |
| download | emacs-fded65c75a6124a95e1b0d05a34a704abaae5281.tar.gz emacs-fded65c75a6124a95e1b0d05a34a704abaae5281.zip | |
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
| -rw-r--r-- | lisp/gnus/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/gnus/shr-color.el | 53 |
2 files changed, 35 insertions, 23 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 2d821b29b64..a3305eb6c53 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2010-11-25 Lars Magne Ingebrigtsen <larsi@gnus.org> | ||
| 2 | |||
| 3 | * shr-color.el (shr-color-visible): Don't bug out if the colour names | ||
| 4 | don't exist. | ||
| 5 | |||
| 1 | 2010-11-25 Katsumi Yamaoka <yamaoka@jpl.org> | 6 | 2010-11-25 Katsumi Yamaoka <yamaoka@jpl.org> |
| 2 | 7 | ||
| 3 | * mml.el (mml-preview): Make sure to bind gnus-displaying-mime to nil, | 8 | * mml.el (mml-preview): Make sure to bind gnus-displaying-mime to nil, |
diff --git a/lisp/gnus/shr-color.el b/lisp/gnus/shr-color.el index 2a4a6b3d4b7..c5ee8c721c8 100644 --- a/lisp/gnus/shr-color.el +++ b/lisp/gnus/shr-color.el | |||
| @@ -324,29 +324,36 @@ If FIXED-BACKGROUND is set, and if the color are not visible, a | |||
| 324 | new background color will not be computed. Only the foreground | 324 | new background color will not be computed. Only the foreground |
| 325 | color will be adapted to be visible on BG." | 325 | color will be adapted to be visible on BG." |
| 326 | ;; Convert fg and bg to CIE Lab | 326 | ;; Convert fg and bg to CIE Lab |
| 327 | (let* ((fg-lab (apply 'rgb->lab (rgb->normalize fg))) | 327 | (let ((fg-norm (rgb->normalize fg)) |
| 328 | (bg-lab (apply 'rgb->lab (rgb->normalize bg))) | 328 | (bg-norm (rgb->normalize bg))) |
| 329 | ;; Compute color distance using CIE DE 2000 | 329 | (if (or (null fg-norm) |
| 330 | (fg-bg-distance (color-lab-ciede2000 fg-lab bg-lab)) | 330 | (null bg-norm)) |
| 331 | ;; Compute luminance distance (substract L component) | 331 | (list bg fg) |
| 332 | (luminance-distance (abs (- (car fg-lab) (car bg-lab))))) | 332 | (let* ((fg-lab (apply 'rgb->lab fg-norm)) |
| 333 | (if (and (>= fg-bg-distance shr-color-visible-distance-min) | 333 | (bg-lab (apply 'rgb->lab bg-norm)) |
| 334 | (>= luminance-distance shr-color-visible-luminance-min)) | 334 | ;; Compute color distance using CIE DE 2000 |
| 335 | (list bg fg) | 335 | (fg-bg-distance (color-lab-ciede2000 fg-lab bg-lab)) |
| 336 | ;; Not visible, try to change luminance to make them visible | 336 | ;; Compute luminance distance (substract L component) |
| 337 | (let ((Ls (set-minimum-interval (car bg-lab) (car fg-lab) 0 100 | 337 | (luminance-distance (abs (- (car fg-lab) (car bg-lab))))) |
| 338 | shr-color-visible-luminance-min | 338 | (if (and (>= fg-bg-distance shr-color-visible-distance-min) |
| 339 | fixed-background))) | 339 | (>= luminance-distance shr-color-visible-luminance-min)) |
| 340 | (unless fixed-background | 340 | (list bg fg) |
| 341 | (setcar bg-lab (car Ls))) | 341 | ;; Not visible, try to change luminance to make them visible |
| 342 | (setcar fg-lab (cadr Ls)) | 342 | (let ((Ls (set-minimum-interval (car bg-lab) (car fg-lab) 0 100 |
| 343 | (list | 343 | shr-color-visible-luminance-min |
| 344 | (if fixed-background | 344 | fixed-background))) |
| 345 | bg | 345 | (unless fixed-background |
| 346 | (apply 'format "#%02x%02x%02x" | 346 | (setcar bg-lab (car Ls))) |
| 347 | (mapcar (lambda (x) (* (max (min 1 x) 0) 255)) (apply 'lab->rgb bg-lab)))) | 347 | (setcar fg-lab (cadr Ls)) |
| 348 | (apply 'format "#%02x%02x%02x" | 348 | (list |
| 349 | (mapcar (lambda (x) (* (max (min 1 x) 0) 255)) (apply 'lab->rgb fg-lab)))))))) | 349 | (if fixed-background |
| 350 | bg | ||
| 351 | (apply 'format "#%02x%02x%02x" | ||
| 352 | (mapcar (lambda (x) (* (max (min 1 x) 0) 255)) | ||
| 353 | (apply 'lab->rgb bg-lab)))) | ||
| 354 | (apply 'format "#%02x%02x%02x" | ||
| 355 | (mapcar (lambda (x) (* (max (min 1 x) 0) 255)) | ||
| 356 | (apply 'lab->rgb fg-lab)))))))))) | ||
| 350 | 357 | ||
| 351 | (provide 'shr-color) | 358 | (provide 'shr-color) |
| 352 | 359 | ||