From 4d25e4ece0b72d240bb2565f8abb7389e650990a Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Sat, 23 Nov 2024 21:05:11 -0500 Subject: Preview + Unit-tests for color conversions --- internal/colors/rgb.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'internal/colors/rgb.go') diff --git a/internal/colors/rgb.go b/internal/colors/rgb.go index e81aefc..0cc48da 100644 --- a/internal/colors/rgb.go +++ b/internal/colors/rgb.go @@ -1,6 +1,9 @@ package colors -import "math" +import ( + "fmt" + "math" +) type RGB struct { R int // 0-255 @@ -8,6 +11,10 @@ type RGB struct { B int // 0-255 } +func (c RGB) String() string { + return fmt.Sprintf("rgb(%d, %d, %d)", c.R, c.G, c.B) +} + func (c RGB) ToPrecise() PreciseColor { return PreciseColor{ R: float64(c.R) / 255, -- cgit v1.2.3