Skip to content

Commit

Permalink
Renamed vars and simplified Vector2 minus, see #86
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Nov 20, 2017
1 parent e80e432 commit 186ac01
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions js/faradays-law-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ define( function( require ) {
// strings
var faradaysLawTitleString = require( 'string!FARADAYS_LAW/faradays-law.title' );

var tandem = Tandem.rootTandem;

var simOptions = {
credits: {
leadDesign: 'Michael Dubson, Bryce Gruneich',
Expand All @@ -32,7 +30,9 @@ define( function( require ) {

// Create and start the sim
SimLauncher.launch( function() {
var sim = new Sim( faradaysLawTitleString, [ new FaradaysLawScreen( tandem.createTandem( 'faradaysLawScreen' ) ) ], simOptions );
var sim = new Sim( faradaysLawTitleString, [
new FaradaysLawScreen( Tandem.rootTandem.createTandem( 'faradaysLawScreen' ) )
], simOptions );
sim.start();
} );
} );
6 changes: 3 additions & 3 deletions js/faradays-law/model/FaradaysLawModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ define( function( require ) {

// if first coil not visible, check only second coil restrictions
for ( var i = this.showTopCoilProperty.get() ? 0 : 2; i < this.listOfRestrictedBounds.length; i++ ) {
var restricted = this.listOfRestrictedBounds[ i ];
if ( magnetBounds.intersectsBounds( restricted ) ) {
var restrictedBounds = this.listOfRestrictedBounds[ i ];
if ( magnetBounds.intersectsBounds( restrictedBounds ) ) {

// extend area so magnet cannot jump through restricted area on other side of it if mouse far enough
var movingDelta = position.minus( this.magnet.positionProperty.get() );
this.intersectedBounds = restricted.copy();
this.intersectedBounds = restrictedBounds.copy();
if ( Math.abs( movingDelta.y ) > Math.abs( movingDelta.x ) ) {

// vertical direction
Expand Down
6 changes: 3 additions & 3 deletions js/faradays-law/view/BulbNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ define( function( require ) {
filamentShape.lineTo( filamentTopPoint.x + xZig, yPos );
}
filamentShape.lineToPoint( filamentBottomPoint );
var filament = new Path( filamentShape, { stroke: 'black' } );
var filamentNode = new Path( filamentShape, { stroke: 'black' } );

// Create the 'halo' that makes the bulb look like it is shining.
var haloNode = new Node( {
Expand Down Expand Up @@ -118,7 +118,7 @@ define( function( require ) {
this.children = [
bulbBodyFill,
filamentSupportWires,
filament,
filamentNode,
haloNode,
bulbBase,
bulbBodyOutline
Expand All @@ -127,7 +127,7 @@ define( function( require ) {
// Do some last layout
bulbBase.centerY = 0;
bulbBase.left = 0;
haloNode.center = filament.center;
haloNode.center = filamentNode.center;

this.mutate( options );

Expand Down
16 changes: 8 additions & 8 deletions js/faradays-law/view/MagnetFieldLines.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ define( function( require ) {
* @returns {Node}
*/
var createArcWithArrow = function( a, b, arrowPositions, flippedProperty, options ) {
var node = new Node();
var arcWithArrow = new Node();
options = _.extend( {
stroke: '#ffffff',
lineWidth: 3
}, options );

// arc
var ellipticalShape = new Shape().ellipticalArc( 0, 0, a, b, 0, 0, 2 * Math.PI );
node.addChild( new Path( ellipticalShape, {
arcWithArrow.addChild( new Path( ellipticalShape, {
stroke: options.stroke,
lineWidth: options.lineWidth
} ) );
Expand All @@ -104,10 +104,10 @@ define( function( require ) {
flippedProperty.lazyLink( function() {
arrow.rotateAround( arrowPosition, Math.PI );
} );
node.addChild( arrow );
arcWithArrow.addChild( arrow );
} );

return node;
return arcWithArrow;
};

/**
Expand All @@ -117,7 +117,7 @@ define( function( require ) {
* @returns {Node}
*/
var createSideFieldLines = function( flippedProperty, scaleY ) {
var node = new Node();
var sideFieldLinesContainer = new Node();

var dy = 3;

Expand All @@ -126,10 +126,10 @@ define( function( require ) {
var arc = createArcWithArrow( line.a, line.b, line.arrowPositions, flippedProperty );
arc.bottom = 2 - index * dy;
arc.centerX = 0;
node.addChild( arc );
sideFieldLinesContainer.addChild( arc );
} );
node.scale( 1, scaleY );
return node;
sideFieldLinesContainer.scale( 1, scaleY );
return sideFieldLinesContainer;
};

faradaysLaw.register( 'MagnetFieldLines', MagnetFieldLines );
Expand Down
14 changes: 7 additions & 7 deletions js/faradays-law/view/MagnetNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ define( function( require ) {
* @returns {Node}
*/
var drawHalfMagnetNode = function( magnetWidth, magnetHeight, label, backgroundColor, options ) {
var node = new Node();
var halfMagnetNode = new Node();

// add the top and sides to create a 3D appearance
node.addChild( new Path( new Shape()
halfMagnetNode.addChild( new Path( new Shape()
.moveTo( -magnetWidth / 4, -magnetHeight / 2 )
.lineTo( -magnetWidth / 4 + magnetWidth * MAGNET_OFFSET_DX_RATIO, -magnetHeight / 2 - magnetHeight * MAGNET_OFFSET_DY_RATIO )
.lineTo( magnetWidth / 4 + magnetWidth * MAGNET_OFFSET_DX_RATIO, -magnetHeight / 2 - magnetHeight * MAGNET_OFFSET_DY_RATIO )
Expand All @@ -102,7 +102,7 @@ define( function( require ) {
} ) );

// add the front
node.addChild( new Rectangle( -magnetWidth / 4, -magnetHeight / 2, magnetWidth / 2, magnetHeight, {
halfMagnetNode.addChild( new Rectangle( -magnetWidth / 4, -magnetHeight / 2, magnetWidth / 2, magnetHeight, {
fill: backgroundColor
} ) );

Expand All @@ -112,16 +112,16 @@ define( function( require ) {
label.centerY = 0;

// label
node.addChild( label );
halfMagnetNode.addChild( label );

node.mutate( options );
halfMagnetNode.mutate( options );

// this addresses an issue where artifacts were being left on the screen in some browser, see #48
node.addChild( Rectangle.bounds( node.localBounds.dilated( 1 ), {
halfMagnetNode.addChild( Rectangle.bounds( halfMagnetNode.localBounds.dilated( 1 ), {
fill: 'rgba( 0, 0, 0, 0 )'
} ) );

return node;
return halfMagnetNode;
};

faradaysLaw.register( 'MagnetNode', MagnetNode );
Expand Down
4 changes: 2 additions & 2 deletions js/faradays-law/view/MagnetNodeWithField.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ define( function( require ) {

// Translate on drag events
drag: function( event ) {
var point = self.globalToParentPoint( event.pointer.point );
var desiredPosition = point.copy().subtract( magnetOffset );
var parentPoint = self.globalToParentPoint( event.pointer.point );
var desiredPosition = parentPoint.minus( magnetOffset );
model.moveMagnetToPosition( desiredPosition );
}
} );
Expand Down
6 changes: 3 additions & 3 deletions js/faradays-law/view/VoltmeterGauge.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ define( function( require ) {
var arcRadius = 55; // radius of voltmeter scale
var needleColor = '#3954a5'; // blue

// scale
var scale = new Path( new Shape()
// background panel within which the needle moves
var background = new Path( new Shape()
.moveTo( 0, 0 )
.lineTo( 0, -arcRadius )
.moveTo( -arcRadius, 0 )
Expand All @@ -43,7 +43,7 @@ define( function( require ) {
stroke: 'black',
lineWidth: 1
} );
this.addChild( scale );
this.addChild( background );

// plus and minus signs
this.addChild( new PlusNode( {
Expand Down

0 comments on commit 186ac01

Please sign in to comment.