34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { appConfig, type GardenRuntimeSettings } from './config';
|
|
import { writeBrowserStorage } from './utils/browser-storage';
|
|
import { getInitialVibe, type VibePreset } from './vibes';
|
|
|
|
const buildSettings = (vibe: VibePreset): GardenRuntimeSettings => ({
|
|
...appConfig.defaultSettings,
|
|
eraserSize: appConfig.toolbar.eraser.default,
|
|
mirrorSegmentCount: appConfig.toolbar.mirror.default,
|
|
...vibe.settings,
|
|
});
|
|
|
|
export let activeVibe = getInitialVibe();
|
|
|
|
export const settings: GardenRuntimeSettings = {
|
|
...buildSettings(activeVibe),
|
|
};
|
|
|
|
export const applyVibeSettings = (vibe: VibePreset) => {
|
|
activeVibe = vibe;
|
|
Object.assign(settings, {
|
|
...buildSettings(vibe),
|
|
eraserSize: settings.eraserSize,
|
|
adaptiveCapInitial: settings.adaptiveCapInitial,
|
|
adaptiveCapMin: settings.adaptiveCapMin,
|
|
internalRenderAreaMegapixels: settings.internalRenderAreaMegapixels,
|
|
maxAgentCount: settings.maxAgentCount,
|
|
mirrorSegmentCount: settings.mirrorSegmentCount,
|
|
selectedColorIndex: Math.min(settings.selectedColorIndex, vibe.colors.length - 1),
|
|
});
|
|
|
|
writeBrowserStorage(appConfig.storage.vibeKey, vibe.id);
|
|
|
|
return activeVibe;
|
|
};
|