summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/lucasb-eyer/go-colorful/happy_palettegen.go
diff options
context:
space:
mode:
authorCaleb Bassi <calebjbassi@gmail.com>2018-04-14 07:32:04 -0700
committerCaleb Bassi <calebjbassi@gmail.com>2018-04-14 08:02:56 -0700
commitfad8e1a63a809b0c63b23f6f71bf368bdae3f910 (patch)
treec5de6bc2ae0a759cb63cefc1f95a09be0cee0115 /vendor/github.com/lucasb-eyer/go-colorful/happy_palettegen.go
parent70e207f99241b44f1f1ea38525c3c87288aa56b4 (diff)
Diffstat (limited to 'vendor/github.com/lucasb-eyer/go-colorful/happy_palettegen.go')
-rw-r--r--vendor/github.com/lucasb-eyer/go-colorful/happy_palettegen.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/vendor/github.com/lucasb-eyer/go-colorful/happy_palettegen.go b/vendor/github.com/lucasb-eyer/go-colorful/happy_palettegen.go
new file mode 100644
index 0000000..d078a8b
--- /dev/null
+++ b/vendor/github.com/lucasb-eyer/go-colorful/happy_palettegen.go
@@ -0,0 +1,26 @@
+package colorful
+
+import (
+ "math/rand"
+)
+
+// Uses the HSV color space to generate colors with similar S,V but distributed
+// evenly along their Hue. This is fast but not always pretty.
+// If you've got time to spare, use Lab (the non-fast below).
+func FastHappyPalette(colorsCount int) (colors []Color) {
+ colors = make([]Color, colorsCount)
+
+ for i := 0 ; i < colorsCount ; i++ {
+ colors[i] = Hsv(float64(i)*(360.0/float64(colorsCount)), 0.8 + rand.Float64()*0.2, 0.65 + rand.Float64()*0.2)
+ }
+ return
+}
+
+func HappyPalette(colorsCount int) ([]Color, error) {
+ pimpy := func(l, a, b float64) bool {
+ _, c, _ := LabToHcl(l, a, b)
+ return 0.3 <= c && 0.4 <= l && l <= 0.8
+ }
+ return SoftPaletteEx(colorsCount, SoftPaletteSettings{pimpy, 50, true})
+}
+