diff options
author | Thomas White <taw@physics.org> | 2021-04-11 11:04:30 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2021-04-11 11:04:30 +0200 |
commit | cd7f92c7a13370048be66e002285fe4b09846d6e (patch) | |
tree | 4a9cbf323494e9bed2c4dba837740b7032530b0a /guile/starlet/colours.scm | |
parent | fa2751d1201b83e32ba6074e68259ac467595808 (diff) |
Add colour-as-rgb
Diffstat (limited to 'guile/starlet/colours.scm')
-rw-r--r-- | guile/starlet/colours.scm | 19 |
1 files changed, 19 insertions, 0 deletions
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) |