Skip to content
Source
Sign inSign up
samwillis/neonbricks
Open History to see the last commit

catalogue.ts

104 lines2.9 KB

1export type Shape =
2 | "brick"
3 | "plate"
4 | "tile"
5 | "slope"
6 | "wedge"
7 | "arch"
8 | "window"
9 | "round"
10 | "beam"
11 | "pin"
12 | "axle"
13 | "bearing"
14 | "wheel"
15 | "gear"
16 | "hinge"
17 | "hub"
18 | "crank";
19export type Definition = {
20 key: string;
21 name: string;
22 category: "Bricks" | "Plates" | "Shapes" | "Mechanics";
23 shape: Shape;
24 w: number;
25 d: number;
26 h: number;
27 studs: boolean;
28 detail?: number;
29};
30const defs: Definition[] = [];
31const add = (
32 key: string,
33 name: string,
34 category: Definition["category"],
35 shape: Shape,
36 w: number,
37 d: number,
38 h: number,
39 studs = false,
40 detail?: number,
41) => defs.push({ key, name, category, shape, w, d, h, studs, detail });
42for (const [w, d] of [
43 [1, 1],
44 [1, 2],
45 [1, 3],
46 [1, 4],
47 [2, 2],
48 [2, 3],
49 [2, 4],
50])
51 add(`brick-${w}x${d}`, `${w} × ${d} brick`, "Bricks", "brick", w, d, 3, true);
52for (const [w, d] of [
53 [1, 1],
54 [1, 2],
55 [1, 4],
56 [2, 2],
57 [2, 4],
58 [4, 4],
59])
60 add(`plate-${w}x${d}`, `${w} × ${d} plate`, "Plates", "plate", w, d, 1, true);
61for (const [w, d] of [
62 [1, 1],
63 [1, 2],
64 [2, 2],
65])
66 add(`tile-${w}x${d}`, `${w} × ${d} tile`, "Plates", "tile", w, d, 1);
67add("slope-2x2", "2 × 2 slope", "Shapes", "slope", 2, 2, 3);
68add("slope-1x2", "1 × 2 slope", "Shapes", "slope", 1, 2, 3);
69add("wedge", "Wing wedge", "Shapes", "wedge", 2, 3, 1, true);
70add("arch", "4-stud arch", "Shapes", "arch", 4, 1, 6, true);
71add("window", "Window frame", "Shapes", "window", 3, 1, 6);
72add("round", "Round brick", "Shapes", "round", 1, 1, 3, true);
73for (const n of [3, 5, 7])
74 add(`beam-${n}`, `${n}-hole beam`, "Mechanics", "beam", n, 1, 3);
75add("pin", "Connector pin", "Mechanics", "pin", 1, 2, 3);
76for (const n of [4, 6])
77 add(`axle-${n}`, `${n}-stud axle`, "Mechanics", "axle", 1, n, 3);
78add("bearing", "Axle bearing", "Mechanics", "bearing", 1, 1, 3);
79add("wheel", "Wheel + tyre", "Mechanics", "wheel", 3, 1, 9);
80add("gear-12", "12-tooth gear", "Mechanics", "gear", 2, 1, 6, false, 12);
81add("gear-20", "20-tooth gear", "Mechanics", "gear", 3, 1, 9, false, 20);
82add("hinge-a", "Hinge · base", "Mechanics", "hinge", 2, 2, 1, true, 0);
83add("hinge-b", "Hinge · leaf", "Mechanics", "hinge", 2, 2, 1, true, 1);
84add("hub", "Wheel hub", "Mechanics", "hub", 1, 1, 3);
85add("crank", "Crank handle", "Mechanics", "crank", 1, 2, 6);
86export const CATALOGUE = defs;
87export const BY_KEY = Object.fromEntries(defs.map((d) => [d.key, d])) as Record<
88 string,
89 Definition
90>;
91export const COLORS = [
92 { name: "Jade", hex: "#289b74" },
93 { name: "Marigold", hex: "#edbc46" },
94 { name: "Poppy", hex: "#d9594e" },
95 { name: "Sky", hex: "#72a6c8" },
96 { name: "Cobalt", hex: "#486fa4" },
97 { name: "Lilac", hex: "#a18ab9" },
98 { name: "Porcelain", hex: "#eee8dc" },
99 { name: "Blush", hex: "#d6a99a" },
100 { name: "Tangerine", hex: "#db8650" },
101 { name: "Graphite", hex: "#3c4445" },
102 { name: "Sand", hex: "#b9aa88" },
103 { name: "Seafoam", hex: "#9fc5b4" },
104];