fixed string->color

This commit is contained in:
Johan Ceuppens 2012-01-16 22:36:10 +00:00
parent b87531989a
commit e62303f795
1 changed files with 17 additions and 17 deletions

View File

@ -65,10 +65,10 @@
(define (string->color str) (define (string->color str)
(let ((colornumber 0)) (let ((colornumber 0))
(do ((i 0 (+ i 1))) (do ((i (- (string-length str) 1) (- i 1)))
((< i (string-length str)) colornumber) ((< i 0) colornumber)
(let* ((c (string-ref str i)) (let ((c (string-ref str i)))
(n (cond ((or (eq? c #\a)(eq? c #\A)) (let ((n (cond ((or (eq? c #\a)(eq? c #\A))
10) 10)
((or (eq? c #\b)(eq? c #\B)) ((or (eq? c #\b)(eq? c #\B))
11) 11)
@ -81,7 +81,7 @@
((or (eq? c #\f)(eq? c #\F)) ((or (eq? c #\f)(eq? c #\F))
15) 15)
(else (string->number (string c)))))) (else (string->number (string c))))))
(set! colornumber (+ (* n 16) colornumber)))))) (set! colornumber (+ (* (+ n 1) 16 i) colornumber)))))))
(define (little-endian->big-endian n) (define (little-endian->big-endian n)
(let ((str (string n)) (let ((str (string n))