emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#14074: closed (24.3.50; Convert hsv to rgb)


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#14074: closed (24.3.50; Convert hsv to rgb)
Date: Fri, 15 Nov 2013 04:09:02 +0000

Your message dated Tue, 01 Jan 2002 06:11:23 +0530
with message-id <address@hidden>
and subject line Re: bug#14074: 24.3.50; Convert hsv to rgb
has caused the debbugs.gnu.org bug report #14074,
regarding 24.3.50; Convert hsv to rgb
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
14074: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14074
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 24.3.50; Convert hsv to rgb Date: Thu, 28 Mar 2013 20:26:15 +0530
Convert hsv to rgb.

Here is a little test case.

    (let ((color-name (format "#%06x" (random #xffffff))))
      (format "color-name: %s  round-tripped: %s"
              color-name
              (apply 'color-rgb-to-hex 
                     (apply 'color-hsv-to-rgb 
                            (apply 'color-rgb-to-hsv 
                                   (color-name-to-rgb color-name))))))

    => "color-name: #01043d  round-tripped: #01033d"
    => "color-name: #1278e2  round-tripped: #1278e2"
    => "color-name: #ffb4bd  round-tripped: #ffb4bd"

One can use `color-hsv-to-rgb' for example in `vc-annotate-color-map'.

=== modified file 'lisp/ChangeLog'
*** lisp/ChangeLog      2013-03-27 16:03:15 +0000
--- lisp/ChangeLog      2013-03-28 14:36:48 +0000
***************
*** 1,3 ****
--- 1,7 ----
+ 2013-03-28  Jambunathan K  <address@hidden>
+ 
+       * color.el (color-hsv-to-rgb): New defun.
+ 
  2013-03-27  Eli Zaretskii  <address@hidden>
  
        * facemenu.el (list-colors-callback): New defvar.

=== modified file 'lisp/color.el'
*** lisp/color.el       2013-01-11 15:04:24 +0000
--- lisp/color.el       2013-03-28 14:40:31 +0000
***************
*** 118,123 ****
--- 118,148 ----
    "Return the color that is the complement of COLOR, in hexadecimal format."
    (apply 'color-rgb-to-hex (color-complement color)))
  
+ (defun color-hsv-to-rgb (h s v)
+   "Convert HSV color components to RGB.
+ HUE should be in radians between 0 and 2*`float-pi', inclusive.
+ SATURATION and VALUE should be between 0.0 and 1.0, inclusive.
+ Return a list (RED GREEN BLUE) where each of the components is
+ between 0.0 and 1.0, inclusive."
+   ;; Convert h from radians to degrees
+   (setq h (/ (* 180.0 h) float-pi))
+   (when (>= h 360) (setq h 0.0))
+   (if (zerop s)
+       (list v v v)
+     (let* ((h (/ h 60.0))
+          (i (floor h))
+          (f (- h i))
+          (l (* v (- 1 s)))
+          (m (* v (- 1 (* s f))))
+          (n (* v (- 1 (* s (- 1 f))))))
+       (cond
+        ((= i 0) (list v n l))
+        ((= i 1) (list m v l))
+        ((= i 2) (list l v n))
+        ((= i 3) (list l m v))
+        ((= i 4) (list n l v))
+        ((= i 5) (list v l m))))))
+ 
  (defun color-rgb-to-hsv (red green blue)
    "Convert RGB color components to HSV.
  RED, GREEN, and BLUE should each be numbers between 0.0 and 1.0,


In GNU Emacs 24.3.50.1 (i686-pc-linux-gnu, GTK+ Version 2.20.1)
 of 2013-03-28 on debian-6.05
Bzr revision: 112161 address@hidden
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
Important settings:
  value of $LANG: en_IN
  locale-coding-system: iso-latin-1-unix
  default enable-multibyte-characters: t




--- End Message ---
--- Begin Message --- Subject: Re: bug#14074: 24.3.50; Convert hsv to rgb Date: Tue, 01 Jan 2002 06:11:23 +0530 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
The snippet I shared is not usable within Emacs.  As OP closing it.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]