Implement date colors
This commit is contained in:
@@ -81,15 +81,15 @@ function GenerateRandomHSL(): Color {
|
||||
const existingColors: Color[] = []
|
||||
|
||||
function GenerateColor(): string {
|
||||
const minDistance = 200
|
||||
const minDistance = 15
|
||||
|
||||
let newColor: Color
|
||||
let isDistinct = false
|
||||
let iterations = 0
|
||||
while (!isDistinct) {
|
||||
iterations++
|
||||
if (iterations > 100) {
|
||||
console.error('Failed to generate a distinct color after 100 iterations')
|
||||
if (iterations > 1000) {
|
||||
console.error('Failed to generate a distinct color after 1000 iterations')
|
||||
break
|
||||
}
|
||||
newColor = GenerateRandomHSL()
|
||||
@@ -101,6 +101,7 @@ function GenerateColor(): string {
|
||||
break
|
||||
}
|
||||
}
|
||||
existingColors.push(newColor)
|
||||
}
|
||||
|
||||
// We can not reach this point without having a color generated
|
||||
|
Reference in New Issue
Block a user