Files
logic-gates/js/constants.js
Jose Luis 99f0fefe5c feat: shift+drag to cut wires and create bus connectors
Hold Shift and drag across wires to create a BUS gate that groups
them together. The cut line shows a live preview with wire count.
BUS gates are pass-through (each input maps to its output) and
render as a thin cyan bar with ports on each side.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 04:39:00 +01:00

38 lines
1.1 KiB
JavaScript

// Gate dimensions and rendering constants
export const GATE_W = 100;
export const GATE_H = 60;
export const COMP_W = 120;
export const PORT_R = 7;
export const GATE_COLORS = {
AND: '#00e599', OR: '#3388ff', NOT: '#ff6644',
NAND: '#e5cc00', NOR: '#cc44ff', XOR: '#ff44aa',
INPUT: '#3388ff', CLOCK: '#ff44aa', OUTPUT: '#ff8833',
BUS: '#44ddff'
};
export const SIGNAL_COLORS = [
'#00e599', '#3388ff', '#ff6644', '#e5cc00',
'#cc44ff', '#ff44aa', '#ff8833', '#44ddff',
'#88ff44', '#ff4488', '#44ffaa', '#ffaa44'
];
export function gateInputCount(type) {
if (type === 'CLOCK' || type === 'INPUT') return 0;
if (type === 'NOT' || type === 'OUTPUT') return 1;
if (type.startsWith('COMPONENT:')) {
// Component types look up their input count from state
return 0; // Will be overridden by lookup in gates.js
}
return 2;
}
export function gateOutputCount(type) {
if (type === 'OUTPUT') return 0;
if (type.startsWith('COMPONENT:')) {
// Component types look up their output count from state
return 0; // Will be overridden by lookup in gates.js
}
return 1;
}