| 1 |
package colorful |
| 2 |
|
| 3 |
// Uses the HSV color space to generate colors with similar S,V but distributed |
| 4 |
// evenly along their Hue. This is fast but not always pretty. |
| 5 |
// If you've got time to spare, use Lab (the non-fast below). |
| 6 |
func FastWarmPaletteWithRand(colorsCount int, rand RandInterface) (colors []Color) { |
| 7 |
colors = make([]Color, colorsCount) |
| 8 |
|
| 9 |
for i := 0; i < colorsCount; i++ { |
| 10 |
colors[i] = Hsv(float64(i)*(360.0/float64(colorsCount)), 0.55+rand.Float64()*0.2, 0.35+rand.Float64()*0.2) |
| 11 |
} |
| 12 |
return |
| 13 |
} |
| 14 |
|
| 15 |
func FastWarmPalette(colorsCount int) (colors []Color) { |
| 16 |
return FastWarmPaletteWithRand(colorsCount, getDefaultGlobalRand()) |
| 17 |
} |
| 18 |
|
| 19 |
func WarmPaletteWithRand(colorsCount int, rand RandInterface) ([]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 SoftPaletteExWithRand(colorsCount, SoftPaletteSettings{warmy, 50, true}, rand) |
| 25 |
} |
| 26 |
|
| 27 |
func WarmPalette(colorsCount int) ([]Color, error) { |
| 28 |
return WarmPaletteWithRand(colorsCount, getDefaultGlobalRand()) |
| 29 |
} |