summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2022-10-18 21:04:11 -0400
committerDavid Thompson <dthompson2@worcester.edu>2022-10-18 21:04:11 -0400
commit2cddd1a22f12b27fe41454e9b71de63d22741c17 (patch)
tree066ca1148b2e8d1e71a1012f0e5dc13c6669aab7
parent5edce04c698cd92149004ead1cad77c481c682e8 (diff)
graphics: color: Define custom color printer.
-rw-r--r--chickadee/graphics/color.scm8
1 files changed, 8 insertions, 0 deletions
diff --git a/chickadee/graphics/color.scm b/chickadee/graphics/color.scm
index fc7a1d6..cadd63d 100644
--- a/chickadee/graphics/color.scm
+++ b/chickadee/graphics/color.scm
@@ -25,8 +25,10 @@
#:use-module (chickadee graphics engine)
#:use-module (chickadee graphics gl)
#:use-module (chickadee math)
+ #:use-module (ice-9 format)
#:use-module (ice-9 match)
#:use-module (srfi srfi-9)
+ #:use-module (srfi srfi-9 gnu)
#:use-module (srfi srfi-1)
#:export (make-color
make-color8
@@ -141,6 +143,12 @@
(define-inlinable (color-a color)
(f32vector-ref (unwrap-color color) 3))
+(define (display-color c port)
+ (format port "#<color r: ~1,3f, g: ~1,3f, b: ~1,3f, a: ~1,3f>"
+ (color-r c) (color-g c) (color-b c) (color-a c)))
+
+(set-record-type-printer! <color> display-color)
+
(define* (make-color r g b #:optional (a 1.0))
(wrap-color (f32vector r g b a)))