Build BeatHound sequencer app
This commit is contained in:
1 parent
226ababcf1
commit
e23825cdb1
49 files changed
+6455
-2
No files matched your search
@@ -0,0 +1,15 @@
|
||||
const FIRST_HUE = 18;
|
||||
const GOLDEN_ANGLE = 137.508;
|
||||
const HUE_CYCLE = 360;
|
||||
|
||||
export function generateUniqueSoundColor(existingColors: readonly string[]): string {
|
||||
const existing = new Set(existingColors);
|
||||
|
||||
for (let index = existingColors.length; index < existingColors.length + HUE_CYCLE; index += 1) {
|
||||
const hue = ((FIRST_HUE + index * GOLDEN_ANGLE) % HUE_CYCLE).toFixed(2);
|
||||
const color = `hsl(${hue} 76% 65%)`;
|
||||
if (!existing.has(color)) return color;
|
||||
}
|
||||
|
||||
throw new Error('Unable to generate a unique sound color.');
|
||||
}
|
||||
Reference in new issue
Block a user