more cleaning up
This commit is contained in:
parent
2c7d72a699
commit
560398fefb
110 changed files with 933 additions and 2647 deletions
|
|
@ -1,33 +1,29 @@
|
|||
import { appConfig, type GardenRuntimeSettings } from './config';
|
||||
import { writeBrowserStorage } from './utils/browser-storage';
|
||||
import { getInitialVibe, VIBE_PRESETS, type VibePreset } from './vibes';
|
||||
import { getInitialVibe, type VibePreset } from './vibes';
|
||||
|
||||
const buildInitialValues = (vibe: VibePreset): GardenRuntimeSettings => ({
|
||||
...appConfig.runtimeSettings.defaults,
|
||||
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: { [key: string]: number } & GardenRuntimeSettings = {
|
||||
...buildInitialValues(activeVibe),
|
||||
export const settings: GardenRuntimeSettings = {
|
||||
...buildSettings(activeVibe),
|
||||
};
|
||||
|
||||
export const resetSettings = () => {
|
||||
Object.assign(settings, buildInitialValues(activeVibe));
|
||||
export const resetSettings = (): GardenRuntimeSettings => {
|
||||
Object.assign(settings, buildSettings(activeVibe));
|
||||
return settings;
|
||||
};
|
||||
|
||||
export const applyVibeSettings = (vibeId: string) => {
|
||||
const vibe = VIBE_PRESETS.find((candidate) => candidate.id === vibeId);
|
||||
if (!vibe) {
|
||||
return activeVibe;
|
||||
}
|
||||
|
||||
export const applyVibeSettings = (vibe: VibePreset) => {
|
||||
activeVibe = vibe;
|
||||
Object.assign(settings, {
|
||||
...buildInitialValues(vibe),
|
||||
agentCount: settings.agentCount,
|
||||
brushEffectDuration: settings.brushEffectDuration,
|
||||
...buildSettings(vibe),
|
||||
eraserSize: settings.eraserSize,
|
||||
mirrorSegmentCount: settings.mirrorSegmentCount,
|
||||
selectedColorIndex: Math.min(settings.selectedColorIndex, vibe.colors.length - 1),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue