Permalink
Browse files

change if-gray-possible

  • Loading branch information...
1 parent c728d17 commit 3b3ff7bfcf48d7c9f184a46935c08146a7568aef @mytoh committed Oct 12, 2012
Showing with 12 additions and 39 deletions.
  1. +12 −39 lib/maali/core.scm
View
@@ -116,49 +116,22 @@
(append (list c c) r))
'() (string->list s))))
+
(define (if-gray-possible red green blue)
- (let ((sep 42.5))
+ (let loop ((sep 42.5)
+ (cnt 1))
(cond
- ((or (< red sep)
- (< green sep)
- (< blue sep))
- (and (< red sep)
- (< green sep)
- (< blue sep)))
- ((or (< red (* sep 2))
- (< green (* sep 2))
- (< blue (* sep 2)))
- (and (< red (* sep 2))
- (< green (* sep 2))
- (< blue (* sep 2))))
- ((or (< red (* sep 3))
- (< green (* sep 3))
- (< blue (* sep 3)))
- (and (< red (* sep 3))
- (< green (* sep 3))
- (< blue (* sep 3))))
- ((or (< red (* sep 4))
- (< green (* sep 4))
- (< blue (* sep 4)))
- (and (< red (* sep 4))
- (< green (* sep 4))
- (< blue (* sep 4))))
- ((or (< red (* sep 5))
- (< green (* sep 5))
- (< blue (* sep 5)))
- (and (< red (* sep 5))
- (< green (* sep 5))
- (< blue (* sep 5))))
- ((or (< red (* sep 6))
- (< green (* sep 6))
- (< blue (* sep 6)))
- (and (< red (* sep 6))
- (< green (* sep 6))
- (< blue (* sep 6))))
- (else
+ ((or (< red (* sep cnt))
+ (< green (* sep cnt))
+ (< blue (* sep cnt)))
+ (and (< red (* sep cnt))
+ (< green (* sep cnt))
+ (< blue (* sep))))
+ ((< cnt 6)
+ (loop sep (+ cnt 1)))
+ ((< 6 cnt)
#t))))
-
(define (colour-rgb r g b)
(string-append
"38"

0 comments on commit 3b3ff7b

Please sign in to comment.