diff options
Diffstat (limited to 'internal/colors/rgb.go')
-rw-r--r-- | internal/colors/rgb.go | 25 |
1 files changed, 25 insertions, 0 deletions
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)), + } +} |