annotate lisp/gnus/shr-color.el @ 111705:cad125981c0f

Merge changes made in Gnus trunk. shr-color.el (shr-color-visible): Really return original background if fixed. shr.el (shr-insert-color-overlay): Replace deprecated syntax. shr.el (shr-tag-body, shr-descend): Add background support. shr.el (shr-tag-title): Add. gnus-sum.el (gnus-summary-articles-in-thread): Fix a bug that causes this function to return incorrect results. shr.el (shr-parse-style): Drop !important from styles. message.el (message-goto-body): Remove the <#secure special-casing, which is too special. mm-util.el (mm-enable-multibyte): Use `to' instead of t. This fixes something or other in Emacs 23, and is backwards compatible. message.el (message-goto-body): Use called-interactively-p. message.el (message-in-body-p): message-goto-body returns point. nnimap.el (nnimap-request-move-article): It's no longer necessary to clear marks before moving, since they're synced from the Gnus side first. gnus-sum.el (gnus-summary-push-marks-to-backend): New function. gnus-sum.el (gnus-summary-move-article): Copy over all marks before moving, so that IMAP doesn't think a new article has arrived. message.el (message-goto-body): called-interactively-p needs a parameter, so use `any'. gnus-cache.el (gnus-summary-insert-cached-articles): Use it. gnus-sum.el (gnus-summary-include-articles): New function. shr.el (shr-tag-table, shr-render-td): Add bgcolor support. shr-color.el (shr-color-visible): Fix docstring. shr.el (shr-insert-background-overlay): Fix typo. shr.el (shr-render-td): Copy the background before rendering.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Wed, 24 Nov 2010 22:54:47 +0000
parents 3fbe2d0ad0f8
children 4483c6423ad1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111678
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
1 ;;; shr-color.el --- Simple HTML Renderer color management
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
2
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
3 ;; Copyright (C) 2010 Free Software Foundation, Inc.
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
4
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
5 ;; Author: Julien Danjou <julien@danjou.info>
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
6 ;; Keywords: html
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
7
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
9
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
13 ;; (at your option) any later version.
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
14
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
19
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
22
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
23 ;;; Commentary:
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
24
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
25 ;; This package handles colors display for shr.
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
26
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
27 ;;; Code:
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
28
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
29 (require 'color-lab)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
30
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
31 (defgroup shr-color nil
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
32 "Simple HTML Renderer colors"
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
33 :group 'shr)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
34
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
35 (defcustom shr-color-visible-luminance-min 40
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
36 "Minimum luminance distance between two colors to be considered visible.
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
37 Must be between 0 and 100."
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
38 :group 'shr
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
39 :type 'float)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
40
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
41 (defcustom shr-color-visible-distance-min 5
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
42 "Minimum color distance between two colors to be considered visible.
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
43 This value is used to compare result for `ciede2000'. Its an
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
44 absolute value without any unit."
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
45 :group 'shr
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
46 :type 'integer)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
47
111693
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
48 (defconst shr-color-html-colors-alist
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
49 '(("AliceBlue" . "#F0F8FF")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
50 ("AntiqueWhite" . "#FAEBD7")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
51 ("Aqua" . "#00FFFF")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
52 ("Aquamarine" . "#7FFFD4")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
53 ("Azure" . "#F0FFFF")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
54 ("Beige" . "#F5F5DC")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
55 ("Bisque" . "#FFE4C4")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
56 ("Black" . "#000000")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
57 ("BlanchedAlmond" . "#FFEBCD")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
58 ("Blue" . "#0000FF")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
59 ("BlueViolet" . "#8A2BE2")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
60 ("Brown" . "#A52A2A")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
61 ("BurlyWood" . "#DEB887")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
62 ("CadetBlue" . "#5F9EA0")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
63 ("Chartreuse" . "#7FFF00")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
64 ("Chocolate" . "#D2691E")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
65 ("Coral" . "#FF7F50")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
66 ("CornflowerBlue" . "#6495ED")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
67 ("Cornsilk" . "#FFF8DC")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
68 ("Crimson" . "#DC143C")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
69 ("Cyan" . "#00FFFF")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
70 ("DarkBlue" . "#00008B")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
71 ("DarkCyan" . "#008B8B")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
72 ("DarkGoldenRod" . "#B8860B")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
73 ("DarkGray" . "#A9A9A9")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
74 ("DarkGrey" . "#A9A9A9")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
75 ("DarkGreen" . "#006400")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
76 ("DarkKhaki" . "#BDB76B")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
77 ("DarkMagenta" . "#8B008B")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
78 ("DarkOliveGreen" . "#556B2F")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
79 ("Darkorange" . "#FF8C00")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
80 ("DarkOrchid" . "#9932CC")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
81 ("DarkRed" . "#8B0000")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
82 ("DarkSalmon" . "#E9967A")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
83 ("DarkSeaGreen" . "#8FBC8F")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
84 ("DarkSlateBlue" . "#483D8B")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
85 ("DarkSlateGray" . "#2F4F4F")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
86 ("DarkSlateGrey" . "#2F4F4F")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
87 ("DarkTurquoise" . "#00CED1")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
88 ("DarkViolet" . "#9400D3")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
89 ("DeepPink" . "#FF1493")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
90 ("DeepSkyBlue" . "#00BFFF")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
91 ("DimGray" . "#696969")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
92 ("DimGrey" . "#696969")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
93 ("DodgerBlue" . "#1E90FF")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
94 ("FireBrick" . "#B22222")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
95 ("FloralWhite" . "#FFFAF0")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
96 ("ForestGreen" . "#228B22")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
97 ("Fuchsia" . "#FF00FF")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
98 ("Gainsboro" . "#DCDCDC")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
99 ("GhostWhite" . "#F8F8FF")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
100 ("Gold" . "#FFD700")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
101 ("GoldenRod" . "#DAA520")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
102 ("Gray" . "#808080")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
103 ("Grey" . "#808080")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
104 ("Green" . "#008000")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
105 ("GreenYellow" . "#ADFF2F")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
106 ("HoneyDew" . "#F0FFF0")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
107 ("HotPink" . "#FF69B4")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
108 ("IndianRed" . "#CD5C5C")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
109 ("Indigo" . "#4B0082")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
110 ("Ivory" . "#FFFFF0")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
111 ("Khaki" . "#F0E68C")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
112 ("Lavender" . "#E6E6FA")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
113 ("LavenderBlush" . "#FFF0F5")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
114 ("LawnGreen" . "#7CFC00")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
115 ("LemonChiffon" . "#FFFACD")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
116 ("LightBlue" . "#ADD8E6")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
117 ("LightCoral" . "#F08080")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
118 ("LightCyan" . "#E0FFFF")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
119 ("LightGoldenRodYellow" . "#FAFAD2")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
120 ("LightGray" . "#D3D3D3")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
121 ("LightGrey" . "#D3D3D3")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
122 ("LightGreen" . "#90EE90")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
123 ("LightPink" . "#FFB6C1")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
124 ("LightSalmon" . "#FFA07A")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
125 ("LightSeaGreen" . "#20B2AA")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
126 ("LightSkyBlue" . "#87CEFA")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
127 ("LightSlateGray" . "#778899")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
128 ("LightSlateGrey" . "#778899")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
129 ("LightSteelBlue" . "#B0C4DE")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
130 ("LightYellow" . "#FFFFE0")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
131 ("Lime" . "#00FF00")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
132 ("LimeGreen" . "#32CD32")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
133 ("Linen" . "#FAF0E6")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
134 ("Magenta" . "#FF00FF")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
135 ("Maroon" . "#800000")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
136 ("MediumAquaMarine" . "#66CDAA")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
137 ("MediumBlue" . "#0000CD")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
138 ("MediumOrchid" . "#BA55D3")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
139 ("MediumPurple" . "#9370D8")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
140 ("MediumSeaGreen" . "#3CB371")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
141 ("MediumSlateBlue" . "#7B68EE")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
142 ("MediumSpringGreen" . "#00FA9A")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
143 ("MediumTurquoise" . "#48D1CC")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
144 ("MediumVioletRed" . "#C71585")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
145 ("MidnightBlue" . "#191970")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
146 ("MintCream" . "#F5FFFA")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
147 ("MistyRose" . "#FFE4E1")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
148 ("Moccasin" . "#FFE4B5")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
149 ("NavajoWhite" . "#FFDEAD")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
150 ("Navy" . "#000080")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
151 ("OldLace" . "#FDF5E6")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
152 ("Olive" . "#808000")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
153 ("OliveDrab" . "#6B8E23")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
154 ("Orange" . "#FFA500")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
155 ("OrangeRed" . "#FF4500")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
156 ("Orchid" . "#DA70D6")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
157 ("PaleGoldenRod" . "#EEE8AA")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
158 ("PaleGreen" . "#98FB98")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
159 ("PaleTurquoise" . "#AFEEEE")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
160 ("PaleVioletRed" . "#D87093")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
161 ("PapayaWhip" . "#FFEFD5")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
162 ("PeachPuff" . "#FFDAB9")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
163 ("Peru" . "#CD853F")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
164 ("Pink" . "#FFC0CB")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
165 ("Plum" . "#DDA0DD")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
166 ("PowderBlue" . "#B0E0E6")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
167 ("Purple" . "#800080")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
168 ("Red" . "#FF0000")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
169 ("RosyBrown" . "#BC8F8F")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
170 ("RoyalBlue" . "#4169E1")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
171 ("SaddleBrown" . "#8B4513")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
172 ("Salmon" . "#FA8072")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
173 ("SandyBrown" . "#F4A460")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
174 ("SeaGreen" . "#2E8B57")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
175 ("SeaShell" . "#FFF5EE")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
176 ("Sienna" . "#A0522D")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
177 ("Silver" . "#C0C0C0")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
178 ("SkyBlue" . "#87CEEB")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
179 ("SlateBlue" . "#6A5ACD")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
180 ("SlateGray" . "#708090")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
181 ("SlateGrey" . "#708090")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
182 ("Snow" . "#FFFAFA")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
183 ("SpringGreen" . "#00FF7F")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
184 ("SteelBlue" . "#4682B4")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
185 ("Tan" . "#D2B48C")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
186 ("Teal" . "#008080")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
187 ("Thistle" . "#D8BFD8")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
188 ("Tomato" . "#FF6347")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
189 ("Turquoise" . "#40E0D0")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
190 ("Violet" . "#EE82EE")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
191 ("Wheat" . "#F5DEB3")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
192 ("White" . "#FFFFFF")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
193 ("WhiteSmoke" . "#F5F5F5")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
194 ("Yellow" . "#FFFF00")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
195 ("YellowGreen" . "#9ACD32"))
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
196 "Alist of HTML colors.
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
197 Each entry should have the form (COLOR-NAME . HEXADECIMAL-COLOR).")
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
198
111678
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
199 (defun shr-color-relative-to-absolute (number)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
200 "Convert a relative NUMBER to absolute. If NUMBER is absolute, return NUMBER.
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
201 This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\"."
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
202 (let ((string-length (- (length number) 1)))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
203 ;; Is this a number with %?
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
204 (if (eq (elt number string-length) ?%)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
205 (/ (* (string-to-number (substring number 0 string-length)) 255) 100)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
206 (string-to-number number))))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
207
111683
01aefe45207c shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111678
diff changeset
208 (defun shr-color-hue-to-rgb (x y h)
01aefe45207c shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111678
diff changeset
209 "Convert X Y H to RGB value."
01aefe45207c shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111678
diff changeset
210 (when (< h 0) (incf h))
01aefe45207c shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111678
diff changeset
211 (when (> h 1) (decf h))
01aefe45207c shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111678
diff changeset
212 (cond ((< h (/ 1 6.0)) (+ x (* (- y x) h 6)))
01aefe45207c shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111678
diff changeset
213 ((< h 0.5) y)
01aefe45207c shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111678
diff changeset
214 ((< h (/ 2.0 3.0)) (+ x (* (- y x) (- (/ 2.0 3.0) h) 6)))
01aefe45207c shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111678
diff changeset
215 (t x)))
01aefe45207c shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111678
diff changeset
216
111678
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
217 (defun shr-color-hsl-to-rgb-fractions (h s l)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
218 "Convert H S L to fractional RGB values."
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
219 (let (m1 m2)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
220 (if (<= l 0.5)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
221 (setq m2 (* l (+ s 1)))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
222 (setq m2 (- (+ l s) (* l s))))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
223 (setq m1 (- (* l 2) m2))
111683
01aefe45207c shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111678
diff changeset
224 (list (shr-color-hue-to-rgb m1 m2 (+ h (/ 1 3.0)))
01aefe45207c shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111678
diff changeset
225 (shr-color-hue-to-rgb m1 m2 h)
01aefe45207c shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111678
diff changeset
226 (shr-color-hue-to-rgb m1 m2 (- h (/ 1 3.0))))))
111678
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
227
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
228 (defun shr-color->hexadecimal (color)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
229 "Convert any color format to hexadecimal representation.
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
230 Like rgb() or hsl()."
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
231 (when color
111693
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
232 (cond
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
233 ;; Hexadecimal color: #abc or #aabbcc
111701
3fbe2d0ad0f8 color-lab.el: Fix all expt calls to use float type.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111696
diff changeset
234 ((string-match
3fbe2d0ad0f8 color-lab.el: Fix all expt calls to use float type.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111696
diff changeset
235 "\\(#[0-9a-fA-F]\\{3\\}[0-9a-fA-F]\\{3\\}?\\)"
111693
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
236 color)
111701
3fbe2d0ad0f8 color-lab.el: Fix all expt calls to use float type.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111696
diff changeset
237 (match-string 1 color))
111693
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
238 ;; rgb() or rgba() colors
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
239 ((or (string-match
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
240 "rgb(\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*)"
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
241 color)
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
242 (string-match
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
243 "rgba(\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*[0-9]*\.?[0-9]+\s*%?\s*)"
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
244 color))
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
245 (format "#%02X%02X%02X"
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
246 (shr-color-relative-to-absolute (match-string-no-properties 1 color))
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
247 (shr-color-relative-to-absolute (match-string-no-properties 2 color))
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
248 (shr-color-relative-to-absolute (match-string-no-properties 3 color))))
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
249 ;; hsl() or hsla() colors
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
250 ((or (string-match
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
251 "hsl(\s*\\([0-9]\\{1,3\\}\\)\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*)"
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
252 color)
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
253 (string-match
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
254 "hsla(\s*\\([0-9]\\{1,3\\}\\)\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*[0-9]*\.?[0-9]+\s*%?\s*)"
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
255 color))
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
256 (let ((h (/ (string-to-number (match-string-no-properties 1 color)) 360.0))
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
257 (s (/ (string-to-number (match-string-no-properties 2 color)) 100.0))
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
258 (l (/ (string-to-number (match-string-no-properties 3 color)) 100.0)))
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
259 (destructuring-bind (r g b)
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
260 (shr-color-hsl-to-rgb-fractions h s l)
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
261 (format "#%02X%02X%02X" (* r 255) (* g 255) (* b 255)))))
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
262 ;; Color names
111696
c63f96430f63 shr-color.el (shr-color->hexadecimal): Ignore case of color names.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111693
diff changeset
263 ((cdr (assoc-string color shr-color-html-colors-alist t)))
111693
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
264 ;; Unrecognized color :(
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
265 (t
1cb16ad0d1bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111683
diff changeset
266 nil))))
111678
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
267
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
268 (defun set-minimum-interval (val1 val2 min max interval &optional fixed)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
269 "Set minimum interval between VAL1 and VAL2 to INTERVAL.
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
270 The values are bound by MIN and MAX.
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
271 If FIXED is t, then val1 will not be touched."
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
272 (let ((diff (abs (- val1 val2))))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
273 (unless (>= diff interval)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
274 (if fixed
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
275 (let* ((missing (- interval diff))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
276 ;; If val2 > val1, try to increase val2
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
277 ;; That's the "good direction"
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
278 (val2-good-direction
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
279 (if (> val2 val1)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
280 (min max (+ val2 missing))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
281 (max min (- val2 missing))))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
282 (diff-val2-good-direction-val1 (abs (- val2-good-direction val1))))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
283 (if (>= diff-val2-good-direction-val1 interval)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
284 (setq val2 val2-good-direction)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
285 ;; Good-direction is not so good, compute bad-direction
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
286 (let* ((val2-bad-direction
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
287 (if (> val2 val1)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
288 (max min (- val1 interval))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
289 (min max (+ val1 interval))))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
290 (diff-val2-bad-direction-val1 (abs (- val2-bad-direction val1))))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
291 (if (>= diff-val2-bad-direction-val1 interval)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
292 (setq val2 val2-bad-direction)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
293 ;; Still not good, pick the best and prefer good direction
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
294 (setq val2
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
295 (if (>= diff-val2-good-direction-val1 diff-val2-bad-direction-val1)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
296 val2-good-direction
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
297 val2-bad-direction))))))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
298 ;; No fixed, move val1 and val2
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
299 (let ((missing (/ (- interval diff) 2.0)))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
300 (if (< val1 val2)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
301 (setq val1 (max min (- val1 missing))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
302 val2 (min max (+ val2 missing)))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
303 (setq val2 (max min (- val2 missing))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
304 val1 (min max (+ val1 missing))))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
305 (setq diff (abs (- val1 val2))) ; Recompute diff
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
306 (unless (>= diff interval)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
307 ;; Not ok, we hit a boundary
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
308 (let ((missing (- interval diff)))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
309 (cond ((= val1 min)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
310 (setq val2 (+ val2 missing)))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
311 ((= val2 min)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
312 (setq val1 (+ val1 missing)))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
313 ((= val1 max)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
314 (setq val2 (- val2 missing)))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
315 ((= val2 max)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
316 (setq val1 (- val1 missing)))))))))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
317 (list val1 val2)))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
318
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
319 (defun shr-color-visible (bg fg &optional fixed-background)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
320 "Check that BG and FG colors are visible if they are drawn on each other.
111705
cad125981c0f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111701
diff changeset
321 Return (bg fg) if they are. If they are too similar, two new
cad125981c0f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111701
diff changeset
322 colors are returned instead.
111678
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
323 If FIXED-BACKGROUND is set, and if the color are not visible, a
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
324 new background color will not be computed. Only the foreground
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
325 color will be adapted to be visible on BG."
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
326 ;; Convert fg and bg to CIE Lab
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
327 (let* ((fg-lab (apply 'rgb->lab (rgb->normalize fg)))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
328 (bg-lab (apply 'rgb->lab (rgb->normalize bg)))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
329 ;; Compute color distance using CIE DE 2000
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
330 (fg-bg-distance (color-lab-ciede2000 fg-lab bg-lab))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
331 ;; Compute luminance distance (substract L component)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
332 (luminance-distance (abs (- (car fg-lab) (car bg-lab)))))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
333 (if (and (>= fg-bg-distance shr-color-visible-distance-min)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
334 (>= luminance-distance shr-color-visible-luminance-min))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
335 (list bg fg)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
336 ;; Not visible, try to change luminance to make them visible
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
337 (let ((Ls (set-minimum-interval (car bg-lab) (car fg-lab) 0 100
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
338 shr-color-visible-luminance-min
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
339 fixed-background)))
111705
cad125981c0f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111701
diff changeset
340 (unless fixed-background
cad125981c0f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111701
diff changeset
341 (setcar bg-lab (car Ls)))
111678
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
342 (setcar fg-lab (cadr Ls))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
343 (list
111705
cad125981c0f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111701
diff changeset
344 (if fixed-background
cad125981c0f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111701
diff changeset
345 bg
cad125981c0f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111701
diff changeset
346 (apply 'format "#%02x%02x%02x"
cad125981c0f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111701
diff changeset
347 (mapcar (lambda (x) (* (max (min 1 x) 0) 255)) (apply 'lab->rgb bg-lab))))
111678
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
348 (apply 'format "#%02x%02x%02x"
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
349 (mapcar (lambda (x) (* (max (min 1 x) 0) 255)) (apply 'lab->rgb fg-lab))))))))
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
350
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
351 (provide 'shr-color)
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
352
3b6c0c4ef2bb shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
353 ;;; shr-color.el ends here