Mercurial > emacs
annotate lisp/gnus/shr-color.el @ 112278:ef719132ddfa
Nuke arch-tags.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 15 Jan 2011 15:16:57 -0800 |
parents | b1eac6d41a93 |
children |
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 |
112235
b1eac6d41a93
[Gnus] Update copyright years.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111732
diff
changeset
|
3 ;; Copyright (C) 2010, 2011 Free Software Foundation, Inc. |
111678
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 |
111711
c4f2770ebd72
shr.el (shr-insert): Fix the way to fold lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111709
diff
changeset
|
29 (require 'color) |
111725
f861f9db770a
nnmail.el (nnmail-expiry-target-group): Protect against degenerate results from -accept-article.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111711
diff
changeset
|
30 (eval-when-compile (require 'cl)) |
111678
3b6c0c4ef2bb
shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
31 |
3b6c0c4ef2bb
shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
32 (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
|
33 "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
|
34 :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
|
35 |
3b6c0c4ef2bb
shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
36 (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
|
37 "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
|
38 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
|
39 :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
|
40 :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
|
41 |
3b6c0c4ef2bb
shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
42 (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
|
43 "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
|
44 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
|
45 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
|
46 :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
|
47 :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
|
48 |
111693
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
49 (defconst shr-color-html-colors-alist |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
50 '(("AliceBlue" . "#F0F8FF") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
51 ("AntiqueWhite" . "#FAEBD7") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
52 ("Aqua" . "#00FFFF") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
53 ("Aquamarine" . "#7FFFD4") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
54 ("Azure" . "#F0FFFF") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
55 ("Beige" . "#F5F5DC") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
56 ("Bisque" . "#FFE4C4") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
57 ("Black" . "#000000") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
58 ("BlanchedAlmond" . "#FFEBCD") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
59 ("Blue" . "#0000FF") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
60 ("BlueViolet" . "#8A2BE2") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
61 ("Brown" . "#A52A2A") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
62 ("BurlyWood" . "#DEB887") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
63 ("CadetBlue" . "#5F9EA0") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
64 ("Chartreuse" . "#7FFF00") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
65 ("Chocolate" . "#D2691E") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
66 ("Coral" . "#FF7F50") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
67 ("CornflowerBlue" . "#6495ED") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
68 ("Cornsilk" . "#FFF8DC") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
69 ("Crimson" . "#DC143C") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
70 ("Cyan" . "#00FFFF") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
71 ("DarkBlue" . "#00008B") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
72 ("DarkCyan" . "#008B8B") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
73 ("DarkGoldenRod" . "#B8860B") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
74 ("DarkGray" . "#A9A9A9") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
75 ("DarkGrey" . "#A9A9A9") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
76 ("DarkGreen" . "#006400") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
77 ("DarkKhaki" . "#BDB76B") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
78 ("DarkMagenta" . "#8B008B") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
79 ("DarkOliveGreen" . "#556B2F") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
80 ("Darkorange" . "#FF8C00") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
81 ("DarkOrchid" . "#9932CC") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
82 ("DarkRed" . "#8B0000") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
83 ("DarkSalmon" . "#E9967A") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
84 ("DarkSeaGreen" . "#8FBC8F") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
85 ("DarkSlateBlue" . "#483D8B") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
86 ("DarkSlateGray" . "#2F4F4F") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
87 ("DarkSlateGrey" . "#2F4F4F") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
88 ("DarkTurquoise" . "#00CED1") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
89 ("DarkViolet" . "#9400D3") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
90 ("DeepPink" . "#FF1493") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
91 ("DeepSkyBlue" . "#00BFFF") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
92 ("DimGray" . "#696969") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
93 ("DimGrey" . "#696969") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
94 ("DodgerBlue" . "#1E90FF") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
95 ("FireBrick" . "#B22222") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
96 ("FloralWhite" . "#FFFAF0") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
97 ("ForestGreen" . "#228B22") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
98 ("Fuchsia" . "#FF00FF") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
99 ("Gainsboro" . "#DCDCDC") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
100 ("GhostWhite" . "#F8F8FF") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
101 ("Gold" . "#FFD700") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
102 ("GoldenRod" . "#DAA520") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
103 ("Gray" . "#808080") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
104 ("Grey" . "#808080") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
105 ("Green" . "#008000") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
106 ("GreenYellow" . "#ADFF2F") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
107 ("HoneyDew" . "#F0FFF0") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
108 ("HotPink" . "#FF69B4") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
109 ("IndianRed" . "#CD5C5C") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
110 ("Indigo" . "#4B0082") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
111 ("Ivory" . "#FFFFF0") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
112 ("Khaki" . "#F0E68C") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
113 ("Lavender" . "#E6E6FA") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
114 ("LavenderBlush" . "#FFF0F5") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
115 ("LawnGreen" . "#7CFC00") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
116 ("LemonChiffon" . "#FFFACD") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
117 ("LightBlue" . "#ADD8E6") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
118 ("LightCoral" . "#F08080") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
119 ("LightCyan" . "#E0FFFF") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
120 ("LightGoldenRodYellow" . "#FAFAD2") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
121 ("LightGray" . "#D3D3D3") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
122 ("LightGrey" . "#D3D3D3") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
123 ("LightGreen" . "#90EE90") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
124 ("LightPink" . "#FFB6C1") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
125 ("LightSalmon" . "#FFA07A") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
126 ("LightSeaGreen" . "#20B2AA") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
127 ("LightSkyBlue" . "#87CEFA") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
128 ("LightSlateGray" . "#778899") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
129 ("LightSlateGrey" . "#778899") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
130 ("LightSteelBlue" . "#B0C4DE") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
131 ("LightYellow" . "#FFFFE0") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
132 ("Lime" . "#00FF00") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
133 ("LimeGreen" . "#32CD32") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
134 ("Linen" . "#FAF0E6") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
135 ("Magenta" . "#FF00FF") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
136 ("Maroon" . "#800000") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
137 ("MediumAquaMarine" . "#66CDAA") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
138 ("MediumBlue" . "#0000CD") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
139 ("MediumOrchid" . "#BA55D3") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
140 ("MediumPurple" . "#9370D8") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
141 ("MediumSeaGreen" . "#3CB371") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
142 ("MediumSlateBlue" . "#7B68EE") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
143 ("MediumSpringGreen" . "#00FA9A") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
144 ("MediumTurquoise" . "#48D1CC") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
145 ("MediumVioletRed" . "#C71585") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
146 ("MidnightBlue" . "#191970") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
147 ("MintCream" . "#F5FFFA") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
148 ("MistyRose" . "#FFE4E1") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
149 ("Moccasin" . "#FFE4B5") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
150 ("NavajoWhite" . "#FFDEAD") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
151 ("Navy" . "#000080") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
152 ("OldLace" . "#FDF5E6") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
153 ("Olive" . "#808000") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
154 ("OliveDrab" . "#6B8E23") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
155 ("Orange" . "#FFA500") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
156 ("OrangeRed" . "#FF4500") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
157 ("Orchid" . "#DA70D6") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
158 ("PaleGoldenRod" . "#EEE8AA") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
159 ("PaleGreen" . "#98FB98") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
160 ("PaleTurquoise" . "#AFEEEE") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
161 ("PaleVioletRed" . "#D87093") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
162 ("PapayaWhip" . "#FFEFD5") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
163 ("PeachPuff" . "#FFDAB9") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
164 ("Peru" . "#CD853F") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
165 ("Pink" . "#FFC0CB") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
166 ("Plum" . "#DDA0DD") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
167 ("PowderBlue" . "#B0E0E6") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
168 ("Purple" . "#800080") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
169 ("Red" . "#FF0000") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
170 ("RosyBrown" . "#BC8F8F") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
171 ("RoyalBlue" . "#4169E1") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
172 ("SaddleBrown" . "#8B4513") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
173 ("Salmon" . "#FA8072") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
174 ("SandyBrown" . "#F4A460") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
175 ("SeaGreen" . "#2E8B57") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
176 ("SeaShell" . "#FFF5EE") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
177 ("Sienna" . "#A0522D") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
178 ("Silver" . "#C0C0C0") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
179 ("SkyBlue" . "#87CEEB") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
180 ("SlateBlue" . "#6A5ACD") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
181 ("SlateGray" . "#708090") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
182 ("SlateGrey" . "#708090") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
183 ("Snow" . "#FFFAFA") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
184 ("SpringGreen" . "#00FF7F") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
185 ("SteelBlue" . "#4682B4") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
186 ("Tan" . "#D2B48C") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
187 ("Teal" . "#008080") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
188 ("Thistle" . "#D8BFD8") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
189 ("Tomato" . "#FF6347") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
190 ("Turquoise" . "#40E0D0") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
191 ("Violet" . "#EE82EE") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
192 ("Wheat" . "#F5DEB3") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
193 ("White" . "#FFFFFF") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
194 ("WhiteSmoke" . "#F5F5F5") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
195 ("Yellow" . "#FFFF00") |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
196 ("YellowGreen" . "#9ACD32")) |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
197 "Alist of HTML colors. |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
198 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
|
199 |
111678
3b6c0c4ef2bb
shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
200 (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
|
201 "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
|
202 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
|
203 (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
|
204 ;; 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
|
205 (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
|
206 (/ (* (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
|
207 (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
|
208 |
111683
01aefe45207c
shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111678
diff
changeset
|
209 (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
|
210 "Convert X Y H to RGB value." |
01aefe45207c
shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111678
diff
changeset
|
211 (when (< h 0) (incf h)) |
01aefe45207c
shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111678
diff
changeset
|
212 (when (> h 1) (decf h)) |
01aefe45207c
shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111678
diff
changeset
|
213 (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
|
214 ((< h 0.5) y) |
01aefe45207c
shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111678
diff
changeset
|
215 ((< 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
|
216 (t x))) |
01aefe45207c
shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111678
diff
changeset
|
217 |
111678
3b6c0c4ef2bb
shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
218 (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
|
219 "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
|
220 (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
|
221 (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
|
222 (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
|
223 (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
|
224 (setq m1 (- (* l 2) m2)) |
111683
01aefe45207c
shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111678
diff
changeset
|
225 (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
|
226 (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
|
227 (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
|
228 |
3b6c0c4ef2bb
shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
229 (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
|
230 "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
|
231 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
|
232 (when color |
111693
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
233 (cond |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
234 ;; 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
|
235 ((string-match |
3fbe2d0ad0f8
color-lab.el: Fix all expt calls to use float type.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111696
diff
changeset
|
236 "\\(#[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
|
237 color) |
111701
3fbe2d0ad0f8
color-lab.el: Fix all expt calls to use float type.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111696
diff
changeset
|
238 (match-string 1 color)) |
111693
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
239 ;; rgb() or rgba() colors |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
240 ((or (string-match |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
241 "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
|
242 color) |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
243 (string-match |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
244 "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
|
245 color)) |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
246 (format "#%02X%02X%02X" |
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 1 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 2 color)) |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
249 (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
|
250 ;; hsl() or hsla() colors |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
251 ((or (string-match |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
252 "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
|
253 color) |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
254 (string-match |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
255 "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
|
256 color)) |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
257 (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
|
258 (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
|
259 (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
|
260 (destructuring-bind (r g b) |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
261 (shr-color-hsl-to-rgb-fractions h s l) |
111711
c4f2770ebd72
shr.el (shr-insert): Fix the way to fold lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111709
diff
changeset
|
262 (color-rgb->hex r g b)))) |
111693
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
263 ;; Color names |
111696
c63f96430f63
shr-color.el (shr-color->hexadecimal): Ignore case of color names.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111693
diff
changeset
|
264 ((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
|
265 ;; Unrecognized color :( |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
266 (t |
1cb16ad0d1bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111683
diff
changeset
|
267 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
|
268 |
3b6c0c4ef2bb
shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
269 (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
|
270 "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
|
271 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
|
272 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
|
273 (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
|
274 (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
|
275 (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
|
276 (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
|
277 ;; 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
|
278 ;; 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
|
279 (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
|
280 (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
|
281 (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
|
282 (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
|
283 (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
|
284 (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
|
285 (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
|
286 ;; 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
|
287 (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
|
288 (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
|
289 (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
|
290 (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
|
291 (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
|
292 (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
|
293 (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
|
294 ;; 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
|
295 (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
|
296 (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
|
297 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
|
298 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
|
299 ;; 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
|
300 (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
|
301 (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
|
302 (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
|
303 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
|
304 (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
|
305 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
|
306 (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
|
307 (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
|
308 ;; 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
|
309 (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
|
310 (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
|
311 (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
|
312 ((= 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
|
313 (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
|
314 ((= 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
|
315 (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
|
316 ((= 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
|
317 (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
|
318 (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
|
319 |
3b6c0c4ef2bb
shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
320 (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
|
321 "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
|
322 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
|
323 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
|
324 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
|
325 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
|
326 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
|
327 ;; Convert fg and bg to CIE Lab |
111711
c4f2770ebd72
shr.el (shr-insert): Fix the way to fold lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111709
diff
changeset
|
328 (let ((fg-norm (color-rgb->normalize fg)) |
c4f2770ebd72
shr.el (shr-insert): Fix the way to fold lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111709
diff
changeset
|
329 (bg-norm (color-rgb->normalize bg))) |
111709
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
330 (if (or (null fg-norm) |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
331 (null bg-norm)) |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
332 (list bg fg) |
111732
6098376da331
color.el: Rename various rgb functions to srgb.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111725
diff
changeset
|
333 (let* ((fg-lab (apply 'color-srgb->lab fg-norm)) |
6098376da331
color.el: Rename various rgb functions to srgb.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111725
diff
changeset
|
334 (bg-lab (apply 'color-srgb->lab bg-norm)) |
111709
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
335 ;; Compute color distance using CIE DE 2000 |
111711
c4f2770ebd72
shr.el (shr-insert): Fix the way to fold lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111709
diff
changeset
|
336 (fg-bg-distance (color-cie-de2000 fg-lab bg-lab)) |
111709
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
337 ;; Compute luminance distance (substract L component) |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
338 (luminance-distance (abs (- (car fg-lab) (car bg-lab))))) |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
339 (if (and (>= fg-bg-distance shr-color-visible-distance-min) |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
340 (>= luminance-distance shr-color-visible-luminance-min)) |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
341 (list bg fg) |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
342 ;; Not visible, try to change luminance to make them visible |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
343 (let ((Ls (set-minimum-interval (car bg-lab) (car fg-lab) 0 100 |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
344 shr-color-visible-luminance-min |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
345 fixed-background))) |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
346 (unless fixed-background |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
347 (setcar bg-lab (car Ls))) |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
348 (setcar fg-lab (cadr Ls)) |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
349 (list |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
350 (if fixed-background |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
351 bg |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
352 (apply 'format "#%02x%02x%02x" |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
353 (mapcar (lambda (x) (* (max (min 1 x) 0) 255)) |
111732
6098376da331
color.el: Rename various rgb functions to srgb.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111725
diff
changeset
|
354 (apply 'color-lab->srgb bg-lab)))) |
111709
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
355 (apply 'format "#%02x%02x%02x" |
4483c6423ad1
shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111705
diff
changeset
|
356 (mapcar (lambda (x) (* (max (min 1 x) 0) 255)) |
111732
6098376da331
color.el: Rename various rgb functions to srgb.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111725
diff
changeset
|
357 (apply 'color-lab->srgb fg-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
|
358 |
3b6c0c4ef2bb
shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
359 (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
|
360 |
3b6c0c4ef2bb
shr.el (shr-tag-color-check): Convert colors to hexadecimal with shr-color->hexadecimal.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
361 ;;; shr-color.el ends here |