From cd7f92c7a13370048be66e002285fe4b09846d6e Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 11 Apr 2021 11:04:30 +0200 Subject: Add colour-as-rgb --- guile/starlet/colours.scm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/guile/starlet/colours.scm b/guile/starlet/colours.scm index c76ebf2..5b2877a 100644 --- a/guile/starlet/colours.scm +++ b/guile/starlet/colours.scm @@ -6,6 +6,7 @@ make-colour-cmy make-colour-rgb colour-as-cmy + colour-as-rgb interpolate-colour white)) @@ -64,6 +65,24 @@ (make-colour-cmy 0 0 0)) +(define (colour-as-rgb col) + (let ((val (colour-value col))) + (case (colour-type col) + + ((rgb) + val) + + ((cmy) + (list (- 100 (red val)) + (- 100 (green val)) + (- 100 (blue val)))) + + (else + (raise-exception (make-exception + (make-exception-with-message "Unrecognised colour type") + (make-exception-with-irritants (colour-type col)))))))) + + (define (colour-as-cmy col) (let ((val (colour-value col))) (case (colour-type col) -- cgit v1.2.3