From a9d926119d90018ba22dcfdcd69fa351421f2f7e Mon Sep 17 00:00:00 2001 From: Craig Gidney Date: Mon, 18 Sep 2017 16:39:12 -0700 Subject: [PATCH] Draw NOT gates as a circled plus except when highlighted --- src/gates/HalfTurnGates.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/gates/HalfTurnGates.js b/src/gates/HalfTurnGates.js index 14695a7d..43e57ca3 100644 --- a/src/gates/HalfTurnGates.js +++ b/src/gates/HalfTurnGates.js @@ -28,28 +28,38 @@ let HalfTurnGates = {}; * @param {!GateDrawParams} args */ function NOT_DRAWER(args) { - let hasSingleWireControl = - args.positionInCircuit !== undefined && - args.stats.circuitDefinition.colHasSingleWireControl(args.positionInCircuit.col); - let hasDoubleWireControl = - args.positionInCircuit !== undefined && - args.stats.circuitDefinition.colHasDoubleWireControl(args.positionInCircuit.col); - if ((!hasSingleWireControl && !hasDoubleWireControl) || args.isHighlighted) { + if (args.isHighlighted) { GatePainting.DEFAULT_DRAWER(args); return; } + // Show a box around the operation when it's not in the circuit. + if (args.positionInCircuit === undefined) { + GatePainting.paintBackground(args); + GatePainting.paintOutline(args); + } + let drawArea = args.rect.scaledOutwardBy(0.6); args.painter.fillCircle(drawArea.center(), drawArea.w / 2); args.painter.strokeCircle(drawArea.center(), drawArea.w / 2); - if (hasSingleWireControl) { + + // Vertical stroke(s). + let hasSingleWireControl = + args.positionInCircuit !== undefined && + args.stats.circuitDefinition.colHasSingleWireControl(args.positionInCircuit.col); + let hasDoubleWireControl = + args.positionInCircuit !== undefined && + args.stats.circuitDefinition.colHasDoubleWireControl(args.positionInCircuit.col); + if (hasSingleWireControl || !hasDoubleWireControl) { args.painter.strokeLine(drawArea.topCenter(), drawArea.bottomCenter()); } if (hasDoubleWireControl) { args.painter.strokeLine(drawArea.topCenter().offsetBy(-1, 0), drawArea.bottomCenter().offsetBy(-1, 0)); args.painter.strokeLine(drawArea.topCenter().offsetBy(+1, 0), drawArea.bottomCenter().offsetBy(+1, 0)); } - let isMeasured = args.stats.circuitDefinition.locIsMeasured( + + // Horizontal stroke(s). + let isMeasured = args.positionInCircuit !== undefined && args.stats.circuitDefinition.locIsMeasured( new Point(args.positionInCircuit.col, args.positionInCircuit.row)); if (isMeasured) { args.painter.strokeLine(drawArea.centerLeft().offsetBy(0, -1), drawArea.centerRight().offsetBy(0, -1));