]> code.delx.au - gnu-emacs/blobdiff - lisp/net/shr-color.el
Update copyright year to 2016
[gnu-emacs] / lisp / net / shr-color.el
index 21f1fc4f0042668b47ae547aa2f0cd514e422e52..67e3b90b9d4058f2f1a074737ec583928d1aeef4 100644 (file)
@@ -1,6 +1,6 @@
 ;;; shr-color.el --- Simple HTML Renderer color management
 
-;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
 
 ;; Author: Julien Danjou <julien@danjou.info>
 ;; Keywords: html
@@ -211,7 +211,7 @@ This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\"."
   "Convert X Y H to RGB value."
   (when (< h 0) (incf h))
   (when (> h 1) (decf h))
-  (cond ((< h (/ 6.0)) (+ x (* (- y x) h 6)))
+  (cond ((< h (/ 6.0)) (+ x (* (- y x) h 6)))
         ((< h 0.5) y)
         ((< h (/ 2.0 3.0)) (+ x (* (- y x) (- (/ 2.0 3.0) h) 6)))
         (t x)))
@@ -223,9 +223,9 @@ This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\"."
         (setq m2 (* l (+ s 1)))
         (setq m2 (- (+ l s) (* l s))))
     (setq m1 (- (* l 2) m2))
-    (list (shr-color-hue-to-rgb m1 m2 (+ h (/ 3.0)))
+    (list (shr-color-hue-to-rgb m1 m2 (+ h (/ 3.0)))
          (shr-color-hue-to-rgb m1 m2 h)
-         (shr-color-hue-to-rgb m1 m2 (- h (/ 3.0))))))
+         (shr-color-hue-to-rgb m1 m2 (- h (/ 3.0))))))
 
 (defun shr-color->hexadecimal (color)
   "Convert any color format to hexadecimal representation.
@@ -242,7 +242,7 @@ Like rgb() or hsl()."
            "rgb(\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*)"
            color)
           (string-match
-           "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*)"
+           "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*)"
            color))
       (format "#%02X%02X%02X"
               (shr-color-relative-to-absolute (match-string-no-properties 1 color))
@@ -253,7 +253,7 @@ Like rgb() or hsl()."
            "hsl(\s*\\([0-9]\\{1,3\\}\\)\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*)"
            color)
           (string-match
-           "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*)"
+           "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*)"
            color))
       (let ((h (/ (string-to-number (match-string-no-properties 1 color)) 360.0))
             (s (/ (string-to-number (match-string-no-properties 2 color)) 100.0))