Fixed Some Issues

This commit is contained in:
meowarex
2025-06-11 02:57:18 +10:00
parent 76644bde1c
commit c2e271cc8c
2 changed files with 18 additions and 7 deletions
+15 -2
View File
@@ -52,14 +52,25 @@ export const Settings = () => {
setBarColor(color);
setCustomInput(color);
settings.barColor = color;
(window as any).updateAudioVisualizer?.();
};
const addCustomColor = () => {
if (customInput && !colorPresets.includes(customInput) && !customColors.includes(customInput)) {
const newCustomColors = [...customColors, customInput];
if (customInput) {
// Trim whitespace and convert to lowercase
const trimmedInput = customInput.trim().toLowerCase();
// Validate hex color format
const hexColorRegex = /^#([0-9a-f]{6}|[0-9a-f]{3})$/i;
if (hexColorRegex.test(trimmedInput) &&
!colorPresets.includes(trimmedInput) &&
!customColors.includes(trimmedInput)) {
const newCustomColors = [...customColors, trimmedInput];
setCustomColors(newCustomColors);
settings.customColors = newCustomColors;
}
}
};
const removeCustomColor = (colorToRemove: string) => {
@@ -84,6 +95,7 @@ export const Settings = () => {
onChange={(_, checked) => {
setBarRounding(checked);
settings.barRounding = checked;
(window as any).updateAudioVisualizer?.();
}}
/>
@@ -97,6 +109,7 @@ export const Settings = () => {
onNumber={(value: number) => {
setBarCount(value);
settings.barCount = value;
(window as any).updateAudioVisualizer?.();
}}
/>
@@ -390,10 +390,8 @@ const updateAudioVisualizer = (): void => {
// use a fixed size that provides enough frequency bins
analyser.fftSize = 512; // Fixed power of 2 - important
analyser.smoothingTimeConstant = config.smoothing;
if (dataArray) {
dataArray = new Uint8Array(analyser.frequencyBinCount);
}
}
if (canvas) {
canvas.width = config.width;