feat: editable labels for INPUT/OUTPUT/CLOCK gates
Double-click any INPUT, OUTPUT, or CLOCK gate to assign a custom label. Labels are shown inside the gate and used in waveform viewer instead of generic IN_0/OUT_0 names. Example circuits now ship with meaningful labels (S, R, D, EN, Q, Q̅, CLK). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -63,8 +63,18 @@ function drawGate(gate) {
|
||||
ctx.textBaseline = 'middle';
|
||||
|
||||
const isIOType = gate.type === 'INPUT' || gate.type === 'OUTPUT' || gate.type === 'CLOCK';
|
||||
|
||||
// Show custom label above the gate if it has one
|
||||
if (gate.label && isIOType) {
|
||||
ctx.font = 'bold 10px "Segoe UI", system-ui, sans-serif';
|
||||
ctx.fillStyle = '#888';
|
||||
ctx.fillText(gate.label, gate.x + GATE_W / 2, gate.y - 8);
|
||||
}
|
||||
|
||||
ctx.font = `bold 14px "Segoe UI", system-ui, sans-serif`;
|
||||
ctx.fillStyle = isActive ? '#fff' : color;
|
||||
ctx.fillText(
|
||||
gate.type === 'CLOCK' ? '⏱ CLK' : gate.type,
|
||||
gate.label && isIOType ? gate.label : (gate.type === 'CLOCK' ? '⏱ CLK' : gate.type),
|
||||
gate.x + GATE_W / 2,
|
||||
gate.y + GATE_H / 2 - (isIOType ? 8 : 0)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user