summaryrefslogtreecommitdiff
path: root/internal/colors/cmyk.go
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2024-11-23 21:05:11 -0500
committerBenjamin Chausse <benjamin@chausse.xyz>2024-11-23 21:05:11 -0500
commit4d25e4ece0b72d240bb2565f8abb7389e650990a (patch)
tree55af982b45d9ed576871c6f3ccf5f800cddc9b56 /internal/colors/cmyk.go
parentb42ab480dd4c4eec83d79bba9400232ddb79f6b1 (diff)
Preview + Unit-tests for color conversions
Diffstat (limited to 'internal/colors/cmyk.go')
-rw-r--r--internal/colors/cmyk.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/colors/cmyk.go b/internal/colors/cmyk.go
index 3460c4e..b5ef223 100644
--- a/internal/colors/cmyk.go
+++ b/internal/colors/cmyk.go
@@ -1,6 +1,9 @@
package colors
-import "math"
+import (
+ "fmt"
+ "math"
+)
type CMYK struct {
C int // 0-100
@@ -9,6 +12,10 @@ type CMYK struct {
K int // 0-100
}
+func (c CMYK) String() string {
+ return fmt.Sprintf("cmyk(%d, %d, %d, %d)", c.C, c.M, c.Y, c.K)
+}
+
func (c CMYK) ToPrecise() PreciseColor {
return PreciseColor{
R: (1 - float64(c.C)/100) * (1 - float64(c.K)/100),