;;; shr-color.el --- Simple HTML Renderer color management
-;; Copyright (C) 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2011 Free Software Foundation, Inc.
;; Author: Julien Danjou <julien@danjou.info>
;; Keywords: html
;;; Code:
(require 'color)
+(eval-when-compile (require 'cl))
(defgroup shr-color nil
"Simple HTML Renderer colors"
(l (/ (string-to-number (match-string-no-properties 3 color)) 100.0)))
(destructuring-bind (r g b)
(shr-color-hsl-to-rgb-fractions h s l)
- (format "#%02X%02X%02X" (* r 255) (* g 255) (* b 255)))))
+ (color-rgb->hex r g b))))
;; Color names
((cdr (assoc-string color shr-color-html-colors-alist t)))
;; Unrecognized color :(
(if (or (null fg-norm)
(null bg-norm))
(list bg fg)
- (let* ((fg-lab (apply 'color-rgb->lab fg-norm))
- (bg-lab (apply 'color-rgb->lab bg-norm))
+ (let* ((fg-lab (apply 'color-srgb->lab fg-norm))
+ (bg-lab (apply 'color-srgb->lab bg-norm))
;; Compute color distance using CIE DE 2000
(fg-bg-distance (color-cie-de2000 fg-lab bg-lab))
;; Compute luminance distance (substract L component)
bg
(apply 'format "#%02x%02x%02x"
(mapcar (lambda (x) (* (max (min 1 x) 0) 255))
- (apply 'color-lab->rgb bg-lab))))
+ (apply 'color-lab->srgb bg-lab))))
(apply 'format "#%02x%02x%02x"
(mapcar (lambda (x) (* (max (min 1 x) 0) 255))
- (apply 'color-lab->rgb fg-lab))))))))))
+ (apply 'color-lab->srgb fg-lab))))))))))
(provide 'shr-color)