From 89094fecf4cb1c018f15c976641cd18c255eac28 Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Sat, 23 Nov 2024 18:12:03 -0500 Subject: Semi-working POC --- internal/colors/rgb.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 internal/colors/rgb.go (limited to 'internal/colors/rgb.go') diff --git a/internal/colors/rgb.go b/internal/colors/rgb.go new file mode 100644 index 0000000..e81aefc --- /dev/null +++ b/internal/colors/rgb.go @@ -0,0 +1,25 @@ +package colors + +import "math" + +type RGB struct { + R int // 0-255 + G int // 0-255 + B int // 0-255 +} + +func (c RGB) ToPrecise() PreciseColor { + return PreciseColor{ + R: float64(c.R) / 255, + G: float64(c.G) / 255, + B: float64(c.B) / 255, + } +} + +func (c RGB) FromPrecise(p PreciseColor) ColorSpace { + return RGB{ + R: int(math.Round(p.R * 255)), + G: int(math.Round(p.G * 255)), + B: int(math.Round(p.B * 255)), + } +} -- cgit v1.2.3