summaryrefslogtreecommitdiff
path: root/internal/colors/rgb.go
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2024-11-23 18:12:03 -0500
committerBenjamin Chausse <benjamin@chausse.xyz>2024-11-23 18:12:03 -0500
commit89094fecf4cb1c018f15c976641cd18c255eac28 (patch)
tree9f6e32c38013bc526399ab324891e0b3269e50dc /internal/colors/rgb.go
Semi-working POC
Diffstat (limited to 'internal/colors/rgb.go')
-rw-r--r--internal/colors/rgb.go25
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)),
+ }
+}