Last active
August 29, 2015 14:20
-
-
Save tek-nishi/0a601b1c3b111d2066ce to your computer and use it in GitHub Desktop.
Convert from HSV to RGB (Emacs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my-color-hsv-to-rgb (h s v) | |
"HSV[0.0, 1.0]からRGB[0.0, 1.0]へ変換する (SOURCE:Wikipedia)" | |
(let ((r v) | |
(g v) | |
(b v)) | |
(if (> s 0) | |
(progn | |
(setq h (* h 6)) | |
(let* ((i (truncate h)) | |
(f (- h i))) | |
(case i | |
(0 (progn | |
(setq g (* g (- 1 (* s (- 1 f))))) | |
(setq b (* b (- 1 s))))) | |
(1 (progn | |
(setq r (* r (- 1 (* s f)))) | |
(setq b (* b (- 1 s))))) | |
(2 (progn | |
(setq r (* r (- 1 s))) | |
(setq b (* b (- 1 (* s (- 1 f))))))) | |
(3 (progn | |
(setq r (* r (- 1 s))) | |
(setq g (* g (- 1 (* s f)))))) | |
(4 (progn | |
(setq r (* r (- 1 (* s (- 1 f))))) | |
(setq g (* g (- 1 s))))) | |
(5 (progn | |
(setq g (* g (- 1 s))) | |
(setq b (* b (- 1 (* s f)))))))))) | |
(list r g b))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment