warm_palettegen.go (757B)
1 package colorful 2 3 import ( 4 "math/rand" 5 ) 6 7 // Uses the HSV color space to generate colors with similar S,V but distributed 8 // evenly along their Hue. This is fast but not always pretty. 9 // If you've got time to spare, use Lab (the non-fast below). 10 func FastWarmPalette(colorsCount int) (colors []Color) { 11 colors = make([]Color, colorsCount) 12 13 for i := 0; i < colorsCount; i++ { 14 colors[i] = Hsv(float64(i)*(360.0/float64(colorsCount)), 0.55+rand.Float64()*0.2, 0.35+rand.Float64()*0.2) 15 } 16 return 17 } 18 19 func WarmPalette(colorsCount int) ([]Color, error) { 20 warmy := func(l, a, b float64) bool { 21 _, c, _ := LabToHcl(l, a, b) 22 return 0.1 <= c && c <= 0.4 && 0.2 <= l && l <= 0.5 23 } 24 return SoftPaletteEx(colorsCount, SoftPaletteSettings{warmy, 50, true}) 25 }