From b1fed4982862e6aca6ac97f847005018e39655c1 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 27 Oct 2000 08:02:35 +0000 Subject: [PATCH] Makefile (munsell-data.el): complement gray data. munsell-conv.el (munsell-split): support the form `Nvalue'. (munsell-round9: ditto. --- Makefile | 5 +++++ munsell-conv.el | 45 +++++++++++++++++++++++++++------------------ munsell-names.el | 14 +++++++------- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index ee990d8..920d268 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,10 @@ +# illuminant C +WHITEx = 0.3101 +WHITEy = 0.3162 + munsell-data.el: all.dat awk 'NR != 1 {printf("(\"%s%s/%s\" . \"CIExyY:%s/%s/%s\")\n", $$1, $$2, $$3, $$4, $$5, $$6 / 100)}' all.dat > _generated + awk 'NR != 1 {printf("(\"N%s\" . \"CIExyY:%s/%s/%s\")\n", $$2, $(WHITEx), $(WHITEy), $$6 / 100)}' all.dat|uniq >> _generated m4 munsell-data.template > munsell-data.el all.dat: diff --git a/munsell-conv.el b/munsell-conv.el index 9a051bc..2e3e76e 100644 --- a/munsell-conv.el +++ b/munsell-conv.el @@ -10,31 +10,40 @@ (value-var (nth 1 vars)) (chroma-var (nth 2 vars))) `(let ((,color-var ,color-expr)) - (if (string-match "^\\(N\\|\\([0-9]+\\(\\.[0-9]*\\)?\\)\\(B\\|BG\\|G\\|GY\\|Y\\|YR\\|R\\|RP\\|P\\|PB\\)\\)\\([0-9]+\\(\\.[0-9]*\\)?\\)/\\([0-9]+\\(\\.[0-9]*\\)?\\)$" ,color-var) + (if (string-match "^N\\([0-9]+\\(\\.[0-9]*\\)?\\)\\|\\([0-9]+\\(\\.[0-9]*\\)?\\)\\(B\\|BG\\|G\\|GY\\|Y\\|YR\\|R\\|RP\\|P\\|PB\\)\\([0-9]+\\(\\.[0-9]*\\)?\\)/\\([0-9]+\\(\\.[0-9]*\\)?\\)$" ,color-var) (let ((,hue-var - (if (match-beginning 2) - (cons (string-to-number (match-string 2 ,color-var)) - (match-string 4 ,color-var)) - (cons 0 (match-string 1 ,color-var)))) - (,value-var (string-to-number (match-string 5 ,color-var))) - (,chroma-var (string-to-number (match-string 7 ,color-var)))) + (if (match-beginning 1) + '(0 . "N") + (cons (string-to-number (match-string 3 ,color-var)) + (match-string 5 ,color-var)))) + (,value-var + (string-to-number + (match-string (if (match-beginning 1) 1 6) ,color-var))) + (,chroma-var + (if (match-beginning 1) + 0 + (string-to-number (match-string 8 ,color-var))))) ,body) ,(or invalid-action `(error "invalid munsell color: %s" ,color-var)))))) (defun munsell-round (h v c hue-round value-round chroma-round) - (concat - (let ((h2 (* 5 (apply hue-round (car h) '(2.5))))) - (if (= (logand h2 1) 0) - (int-to-string (ash h2 -1)) - (concat (int-to-string (ash h2 -1)) ".5"))) - (cdr h) - (if (< v 0.9) - (concat "0." (int-to-string (* 2 (apply value-round v '(0.2))))) - (int-to-string (apply value-round v '(1)))) - "/" - (int-to-string (* 2 (apply chroma-round c '(2)))))) + (let ((c-rounded (* 2 (apply chroma-round c '(2))))) + (concat + (if (= c-rounded 0) + "N" + (let ((h2 (* 5 (apply hue-round (car h) '(2.5))))) + (concat + (int-to-string (ash h2 -1)) + (unless (= (logand h2 1) 0) ".5") + (cdr h)))) + (if (< v 0.9) + (concat "0." (int-to-string (* 2 (apply value-round v '(0.2))))) + (int-to-string (apply value-round v '(1)))) + (if (= c-rounded 0) + "" + (concat "/" (int-to-string c-rounded)))))) (defun munsell-convert (color) (munsell-split color (h v c) diff --git a/munsell-names.el b/munsell-names.el index 5577c1d..259ed79 100644 --- a/munsell-names.el +++ b/munsell-names.el @@ -78,13 +78,13 @@ ("10PB3.5/10" "桔梗" "ききょう") ("7.5P5.0/8.0" "藤" "ふじ") ("5.0RP4.5/14" "牡丹" "ぼたん") -;; ("N1.5/0" "墨" "すみ") -;; ("5.0YR3.0/0.5" "墨橡" "くろつるばみ") -;; ("2.5YR3.0/0.5" "皀" "くり") -;; ("7.5R4.0/0.5" "鈍" "にび") -;; ("5.0B4.0/0.5" "青鈍" "あおにび") -;; ("5.0G4.5/0.5" "利久鼠" "りきゅうねずみ") -;; ("5.0GY5.0/0.5" "灰" "はい") + ("N1.5" "墨" "すみ") + ("5.0YR3.0/0.5" "墨橡" "くろつるばみ") + ("2.5YR3.0/0.5" "皀" "くり") + ("7.5R4.0/0.5" "鈍" "にび") + ("5.0B4.0/0.5" "青鈍" "あおにび") + ("5.0G4.5/0.5" "利久鼠" "りきゅうねずみ") + ("5.0GY5.0/0.5" "灰" "はい") ) "Munsell color names") -- 1.7.10.4