-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
warm_palettegen.go
29 lines (24 loc) · 1.03 KB
/
warm_palettegen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package colorful
// 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 FastWarmPaletteWithRand(colorsCount int, rand RandInterface) (colors []Color) {
colors = make([]Color, colorsCount)
for i := 0; i < colorsCount; i++ {
colors[i] = Hsv(float64(i)*(360.0/float64(colorsCount)), 0.55+rand.Float64()*0.2, 0.35+rand.Float64()*0.2)
}
return
}
func FastWarmPalette(colorsCount int) (colors []Color) {
return FastWarmPaletteWithRand(colorsCount, getDefaultGlobalRand())
}
func WarmPaletteWithRand(colorsCount int, rand RandInterface) ([]Color, error) {
warmy := func(l, a, b float64) bool {
_, c, _ := LabToHcl(l, a, b)
return 0.1 <= c && c <= 0.4 && 0.2 <= l && l <= 0.5
}
return SoftPaletteExWithRand(colorsCount, SoftPaletteSettings{warmy, 50, true}, rand)
}
func WarmPalette(colorsCount int) ([]Color, error) {
return WarmPaletteWithRand(colorsCount, getDefaultGlobalRand())
}