diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2024-11-23 21:05:11 -0500 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2024-11-23 21:05:11 -0500 |
commit | 4d25e4ece0b72d240bb2565f8abb7389e650990a (patch) | |
tree | 55af982b45d9ed576871c6f3ccf5f800cddc9b56 /internal/colors/rgb.go | |
parent | b42ab480dd4c4eec83d79bba9400232ddb79f6b1 (diff) |
Preview + Unit-tests for color conversions
Diffstat (limited to 'internal/colors/rgb.go')
-rw-r--r-- | internal/colors/rgb.go | 9 |
1 files changed, 8 insertions, 1 deletions
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, |