X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=color.lisp;h=d674886165f061ffa5424ad2f037305339bfd65c;hb=37c6b4baf974335c53828b760ed023f37098cf19;hp=11f809eb33094e3e341acb9c329342fd3129d2a3;hpb=f6555d4ded6e1612ef1042fdbfd8df3c8eb5df18;p=kmrcl.git diff --git a/color.lisp b/color.lisp index 11f809e..d674886 100644 --- a/color.lisp +++ b/color.lisp @@ -268,7 +268,7 @@ (when (<= (abs (- v1 v2)) value-range) t)) (t - (when (and (<= (hue-difference-fixnum h1 h2) hue-range) + (when (and (<= (abs (hue-difference-fixnum h1 h2)) hue-range) (<= (abs (- v1 v2)) value-range) (<= (abs (- s1 s2)) saturation-range)) t)))) @@ -277,7 +277,12 @@ (defun hue-difference (h1 h2) "Return difference between two hues around 360 degree circle" - (when (and h1 h2) + (cond + ((and (null h1) (null h2)) + t) + ((or (null h1) (null h2)) + 360) + (t (let ((diff (- h2 h1))) (cond ((< diff -180) @@ -286,12 +291,17 @@ ((> diff 180) (- (- 360 diff))) (t - diff))))) + diff)))))) (defun hue-difference-fixnum (h1 h2) "Return difference between two hues around 360 degree circle" - (when (and h1 h2) + (cond + ((and (null h1) (null h2)) + t) + ((or (null h1) (null h2)) + 360) + (t (locally (declare (type fixnum h1 h2)) (let ((diff (- h2 h1))) (cond @@ -301,5 +311,5 @@ ((> diff 180) (- (- 360 diff))) (t - diff)))))) - \ No newline at end of file + diff))))))) +