Skip to content

Commit

Permalink
Draw NOT gates as a circled plus except when highlighted
Browse files Browse the repository at this point in the history
  • Loading branch information
Strilanc committed Sep 18, 2017
1 parent dd658e8 commit a9d9261
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/gates/HalfTurnGates.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit a9d9261

Please sign in to comment.