(define o (lambda funs (lambda (x) (let kernel ((remaining (reverse funs)) (val x)) (if (null? remaining) val (kernel (cdr remaining) ((car remaining) val))))))) (define rgb.map (lambda (func color) (rgb.new (func (rgb.red color)) (func (rgb.green color)) (func (rgb.blue color))))) (define rgb.phaseshift (l-s rgb.map (o (r-s modulo 256) (l-s + 128)))) (define rgb.darker (l-s rgb.map (o (l-s min 255) (r-s - 16)))) (define rgb.lighter (l-s rgb.map (o (l-s max 0) (r-s + 16)))) (define rgb.rotate (lambda (color) (rgb.new (rgb.green color) (rgb.blue color) (rgb.red color)))) (define rgb.complement (l-s rgb.map (l-s - 255))) (define rgb.flatten (lambda (unit color) (rgb.map (o (l-s * unit) floor (r-s / unit)) color))) (define rgb.redder (lambda (color) (rgb.new (min 255 (+ 8 (rgb.red color))) (rgb.green color) (rgb.blue color)))) (define rgb.greener (lambda (color) (rgb.new (rgb.red color) (min 255 (+ 8 (rgb.green color))) (rgb.blue color)))) (define rgb.bluer (lambda (color) (rgb.new (rgb.red color) (rgb.green color) (min 255 (+ 8 (rgb.blue color)))))) (define rgb.add (lambda (colorA colorB) (rgb.new (min 255 (+ (rgb.red colorA) (rgb.red colorB))) (min 255 (+ (rgb.green colorA) (rgb.green colorB))) (min 255 (+ (rgb.blue colorA) (rgb.blue colorB)))))) (define rgb.average (lambda (colorA colorB) (rgb.new (round (/ (+ (rgb.red colorA) (rgb.red colorB)) 2)) (round (/ (+ (rgb.green colorA) (rgb.green colorB)) 2)) (round (/ (+ (rgb.blue colorA) (rgb.blue colorB)) 2)))))