From d4d0431f0775262264f43ecb0d8450d9b2af6384 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 13 Feb 2022 18:43:32 +0100 Subject: Write colours as inexact numbers to three significant figures --- guile/starlet/colours.scm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/guile/starlet/colours.scm b/guile/starlet/colours.scm index f18b986..37c19dc 100644 --- a/guile/starlet/colours.scm +++ b/guile/starlet/colours.scm @@ -75,13 +75,15 @@ (colour-type col) (colour-value col))) +(define (three-sf n) + (/ (round (* (exact->inexact n) 10)) 10)) (define-method (write (col ) port) (let ((cmy (colour-as-cmy col))) (format port "(make-colour-cmy ~a ~a ~a)" - (cyan cmy) - (magenta cmy) - (yellow cmy)))) + (three-sf (cyan cmy)) + (three-sf (magenta cmy)) + (three-sf (yellow cmy))))) (define (make-colour-cmy c m y) -- cgit v1.2.3