-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstants.ts
More file actions
29 lines (25 loc) · 945 Bytes
/
constants.ts
File metadata and controls
29 lines (25 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { ComponentType, CircuitComponent } from './types';
export const GRID_SIZE = 20;
export const COMPONENT_WIDTH = 80;
export const COMPONENT_HEIGHT = 60;
export const GATE_COLORS: Record<ComponentType, string> = {
AND: '#ef4444', // Red
OR: '#3b82f6', // Blue
NOT: '#eab308', // Yellow
NAND: '#f97316', // Orange
NOR: '#06b6d4', // Cyan
XOR: '#8b5cf6', // Violet
LEVER: '#10b981', // Emerald
BUTTON: '#10b981', // Emerald
BULB: '#f59e0b', // Amber
IC: '#64748b', // Slate
};
export const PIN_OFFSET = 10; // Distance from edge
export const getComponentHeight = (component: CircuitComponent): number => {
const maxPins = Math.max(component.inputs.length, component.outputs.length);
// Base height is 60.
// We want to ensure pins aren't too crowded.
// (pins + 1) segments. If we allocate 15px per segment:
const requiredHeight = (maxPins + 1) * 15;
return Math.max(COMPONENT_HEIGHT, requiredHeight);
};