;; color representation: ;; '(red green blue), 0.0 <= value <= 1.0 (define (red c) (car c)) (define (green c) (cadr c)) (define (blue c) (caddr c)) (define cyan red) (define magenta green) (define yellow blue) (define (black c) (cadddr c)) (define (rgb->cmy rgb) (map (lambda (x) (- 1.0 x)) rgb)) (define cmy->rgb rgb->cmy) (define (rgb->cmyk rgb) ;; black intensity is the minimum of C, M, Y. ;; This common component is then subtracted. (let* ((cmy (rgb->cmy rgb)) (k (apply min cmy))) (append (if (> k 0.0) (map (lambda (x) (- x k)) cmy) cmy) (list k)))) (define (cmyk->rgb cmyk) (let ((clip (lambda (x) (if (> x 1.0) 1.0 x))) (invert (lambda (x) (- 1.0 x))) (k (black cmyk))) (map (lambda (x) (invert (clip (+ x k)))) (list (cyan cmyk) (magenta cmyk) (yellow cmyk)))))