wip
This commit is contained in:
commit
d8f2407ddf
44 changed files with 10377 additions and 0 deletions
64
src/lib/defaults.ts
Normal file
64
src/lib/defaults.ts
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import type { Project, Room, Wall, UrlState } from './types';
|
||||
export function rectangle(id = 'room-1', name = 'Living room', width = 4800, height = 3600): Room {
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
direction: 0,
|
||||
walls: [width, height, width, height].map((length, i) => ({
|
||||
id: `${id}-w${i + 1}`,
|
||||
length,
|
||||
turn: 90,
|
||||
doors: i === 3 ? [{ id: `${id}-door-1`, offset: 500, width: 826 }] : [],
|
||||
})),
|
||||
};
|
||||
}
|
||||
export function fireplace(id: string, name: string): Room {
|
||||
const measures = [
|
||||
[4800, 90],
|
||||
[3600, 90],
|
||||
[1650, 90],
|
||||
[450, -90],
|
||||
[1500, -90],
|
||||
[450, 90],
|
||||
[1650, 90],
|
||||
[3600, 90],
|
||||
];
|
||||
const walls: Wall[] = measures.map(([length, turn], i) => ({
|
||||
id: `${id}-w${i + 1}`,
|
||||
length,
|
||||
turn,
|
||||
doors: i === 7 ? [{ id: `${id}-door-1`, offset: 500, width: 826 }] : [],
|
||||
}));
|
||||
return { id, name, direction: 0, walls };
|
||||
}
|
||||
export function defaultProject(): Project {
|
||||
return {
|
||||
version: 1,
|
||||
name: 'My flooring project',
|
||||
rooms: [rectangle()],
|
||||
tolerance: 10,
|
||||
flooring: {
|
||||
length: 1200,
|
||||
width: 190,
|
||||
gap: 10,
|
||||
pattern: 'brick',
|
||||
minOffset: 300,
|
||||
maxOffset: 600,
|
||||
minLength: 200,
|
||||
minWidth: 60,
|
||||
kerf: 3,
|
||||
},
|
||||
skirting: { stockLengths: [2400], thickness: 18, minLength: 200, kerf: 3 },
|
||||
};
|
||||
}
|
||||
export function defaultState(): UrlState {
|
||||
return {
|
||||
project: defaultProject(),
|
||||
view: { roomId: 'room-1', selectedPiece: null },
|
||||
};
|
||||
}
|
||||
export function nextId(prefix: string, existing: string[]): string {
|
||||
let n = 1;
|
||||
while (existing.includes(`${prefix}-${n}`)) n++;
|
||||
return `${prefix}-${n}`;
|
||||
}
|
||||
Loading…
Reference in a new issue