Skip to content

Commit

Permalink
address duplicate 'arms' code in GuideNode, #376
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Mar 15, 2022
1 parent 2e63eb7 commit bbdc77f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions js/common/view/GuideNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,8 @@ class GuideNode extends Node {
const fulcrumNode = new Circle( FULCRUM_RADIUS, FULCRUM_OPTIONS );

// The arms are two rectangles, with left center side laying on fulcrum initially.
const armOptions = {
stroke: ARM_STROKE,
fill: armColor
};
const incidentArmNode = new Rectangle( fulcrumNode.x, fulcrumNode.y - ARM_HEIGHT / 2, ARM_WIDTH, ARM_HEIGHT, armOptions );
const transmittedArmNode = new Rectangle( fulcrumNode.x, fulcrumNode.y - ARM_HEIGHT / 2, ARM_WIDTH, ARM_HEIGHT, armOptions );
const incidentArmNode = createArmNode( armColor );
const transmittedArmNode = createArmNode( armColor );

const options = optionize<GuideNodeOptions, {}, NodeOptions>( {

Expand Down Expand Up @@ -147,6 +143,17 @@ class GuideNode extends Node {
}
}

/**
* Creates one of the guide arms.
* @param armColor
*/
function createArmNode( armColor: IColor ) {
return new Rectangle( 0, 0, ARM_WIDTH, ARM_HEIGHT, {
stroke: ARM_STROKE,
fill: armColor
} );
}

/**
* Sets the position of an arm such that its left center is on the fulcrum point.
* @param armNode
Expand Down

0 comments on commit bbdc77f

Please sign in to comment.