unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dov Grobgeld <dov.grobgeld@gmail.com>
To: emacs-devel <emacs-devel@gnu.org>
Subject: [PATCH] color-hsv-to-rgb
Date: Mon, 16 Oct 2023 10:28:44 +0300	[thread overview]
Message-ID: <CA++fsGEWeYerMqb1Mgd0bW7rQRvhqkeK_g296D8rNpTMv2fzTw@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 246 bytes --]

Hello.

I would like to do my first(!) contribution to emacs with the attached
patch. Is there interest, or is it too trivial? Do I need to do a copyright
assignment? Is there a guide for dummies on how to do that?

With hope for better times...

[-- Attachment #1.2: Type: text/html, Size: 842 bytes --]

[-- Attachment #2: color-hsv-to-rgb.patch --]
[-- Type: text/x-patch, Size: 1110 bytes --]

diff --git a/lisp/color.el b/lisp/color.el
index f68cf5e6b17..37f11f23c7c 100644
--- a/lisp/color.el
+++ b/lisp/color.el
@@ -123,6 +123,26 @@ color-complement-hex
   "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 hue, saturation and value to their RGB representation.
+H, S, and V should each be numbers between 0.0 and 1.0, inclusive.
+Return a list (RED GREEN BLUE), where each element is between 0.0 and 1.0,
+inclusive."
+  (let* ((I (floor (* 6 H)))
+         (F (- (* H 6) I))
+         (P (* V (- 1.0 S)))
+         (Q (* V (- 1.0 (* F S))))
+         (T (* V (- 1.0 (* (- 1.0 F) S))))
+         (I (mod I 6)))
+    (cond
+     ((= I 0) (list V T P))
+     ((= I 1) (list Q V P))
+     ((= I 2) (list P V T))
+     ((= I 3) (list P Q V))
+     ((= I 4) (list T P V))
+     ((= I 5) (list V P Q))
+     (t (list 0 0 0)))))
+
 (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,

             reply	other threads:[~2023-10-16  7:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-16  7:28 Dov Grobgeld [this message]
2023-10-16  7:59 ` [PATCH] color-hsv-to-rgb Stefan Kangas
2023-10-19 19:58   ` Jim Porter
2023-10-19 20:12     ` [External] : " Drew Adams
2023-10-19 21:22       ` Stefan Kangas
2023-10-19 21:35         ` Drew Adams
2023-10-20  6:09           ` Eli Zaretskii
2023-10-20 15:04             ` Drew Adams
2023-10-20 17:59               ` Eli Zaretskii
2023-10-16 12:05 ` Eli Zaretskii
2023-10-17  6:12   ` Dov Grobgeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA++fsGEWeYerMqb1Mgd0bW7rQRvhqkeK_g296D8rNpTMv2fzTw@mail.gmail.com \
    --to=dov.grobgeld@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).