Implement date colors

This commit is contained in:
2024-06-12 20:01:01 +02:00
parent c83f51a00b
commit 057377186a
3 changed files with 21 additions and 4 deletions

View File

@@ -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