Skip to content

Commit 1a0db4f

Browse files
committed
Generate more colors using hsl()
1 parent 31af226 commit 1a0db4f

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/draw.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ import { Boundaries, Size, State, ViewportNumber, ViewportPattern } from './type
99

1010
// -- constants
1111

12-
// todo: handle colors in a better way
13-
const COLORS = '0123456789abcdef'
14-
.split('')
15-
.reverse()
16-
.map(a => `#fa${a}`)
12+
const COLOR_SIZE = 50
13+
const COLORS = Array(COLOR_SIZE).fill(undefined).map((_, i) => {
14+
const frac = i / COLOR_SIZE
15+
16+
const hue = (80 + 360 * frac) % 360
17+
const saturation = 50 + (frac * 30)
18+
const lightness = 60
19+
20+
return `hsl(${hue} ${saturation}% ${lightness}%)`
21+
})
1722

1823
const MIN_DEPTH = 3
1924
const MAX_DEPTH = Infinity

0 commit comments

Comments
 (0)