Function for Converting Hue to RGB
(define pi 3.14159265358979)
(define deg2rad
(lambda (d)
(* d (/ (* 2.0 pi) 360))))
(define rad2deg
(lambda (r)
(* r (/ 360.0 (* 2.0 pi)))))
(define cosd
(lambda (x)
(cos (deg2rad x))))
(define sind
(lambda (x)
(sin (deg2rad x))))
(define sqrt3 (sqrt 3.0))
(define normalize
(lambda (x)
(inexact->exact
(floor (/ (* x 256) sqrt3)))))
(define hue->rgb
(lambda (h)
(cond ((< h 0)
(hue->rgb (+ h 360)))
((and (<= 0 h) (< h 120))
(let* ((r (/ (+ 1 (/ (cosd h)
(cosd (- 60 h))))
sqrt3))
(g (- sqrt3 r)))
(map normalize (list r g 0))))
((and (<= 120 h) (< h 240))
(let* ((g (/ (+ 1 (/ (cosd (- h 120))
(cosd (- 180 h))))
sqrt3))
(b (- sqrt3 g)))
(map normalize (list 0 g b))))
((and (<= 240 h) (< h 360))
(let* ((b (/ (+ 1 (/ (cosd (- h 240))
(cosd (- 300 h))))
sqrt3))
(r (- sqrt3 b)))
(map normalize (list r 0 b))))
(else
(hue->rgb (- h 360))))))