aboutsummaryrefslogtreecommitdiff
path: root/guile
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2022-02-13 18:43:32 +0100
committerThomas White <taw@physics.org>2022-02-13 19:04:16 +0100
commitd4d0431f0775262264f43ecb0d8450d9b2af6384 (patch)
tree83b7ee3dee670ba773884e5d0a9c8d788d91f477 /guile
parent9b59e3933cb8e7c4e67898f9926fb9d38a2da076 (diff)
Write colours as inexact numbers to three significant figures
Diffstat (limited to 'guile')
-rw-r--r--guile/starlet/colours.scm8
1 files 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 <colour>) 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)