Skip to content

Commit

Permalink
mutate through options, #51
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Jun 24, 2017
1 parent 84def0a commit fed6097
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
5 changes: 4 additions & 1 deletion js/ohms-law/view/FormulaNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ define( function( require ) {
* @param {Property.<number>} currentProperty
* @param {Property.<number>} voltageProperty
* @param {Property.<number>} resistanceProperty
* @param {Object} options
* @constructor
*/
function FormulaNode( currentProperty, voltageProperty, resistanceProperty ) {
function FormulaNode( currentProperty, voltageProperty, resistanceProperty, options ) {

Node.call( this );

Expand Down Expand Up @@ -122,6 +123,8 @@ define( function( require ) {
// TODO: Performance: consider not updating the matrix if it hasn't changed (if textData.x, textData.scaleA, and textData.scaleB haven't changed)
} );
} );

this.mutate(options);
}

ohmsLaw.register( 'FormulaNode', FormulaNode );
Expand Down
17 changes: 9 additions & 8 deletions js/ohms-law/view/OhmsLawScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ define( function( require ) {
ScreenView.call( this );

// Circuit node with readout node
var wireBox = new WireBox( model.voltageProperty, model.resistanceProperty, model.currentProperty ).mutate( { pickable: false } );
var wireBox = new WireBox( model.voltageProperty, model.resistanceProperty, model.currentProperty, {
pickable: false,
x: 70, // Layout of the WireBox
y: 380
} );
this.addChild( wireBox );

// Node of ohm's law equation. Layout is hardwired, see FormulaNode.
var formulaNode = new FormulaNode( model.currentProperty, model.voltageProperty, model.resistanceProperty ).mutate( { pickable: false } );

var formulaNode = new FormulaNode( model.currentProperty, model.voltageProperty, model.resistanceProperty, {
pickable: false
} );
this.addChild( formulaNode );
this.addChild( wireBox );

// Layout of the wirebox
wireBox.x = 70;
wireBox.y = 380;

// Create and add control panel with sliders.
var controlPanel = new ControlPanel( model.voltageProperty, model.resistanceProperty );
Expand Down
5 changes: 4 additions & 1 deletion js/ohms-law/view/WireBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ define( function( require ) {
* @param {Property.<number>} voltageProperty
* @param {Property.<number>} resistanceProperty
* @param {Property.<number>} currentProperty
* @param {Object} options
* @constructor
*/
function WireBox( voltageProperty, resistanceProperty, currentProperty ) {
function WireBox( voltageProperty, resistanceProperty, currentProperty, options ) {

Node.call( this );

Expand Down Expand Up @@ -70,6 +71,8 @@ define( function( require ) {
centerX: WIDTH / 2
} );
this.addChild( currentReadoutPanel );

this.mutate(options);
}

ohmsLaw.register( 'WireBox', WireBox );
Expand Down

0 comments on commit fed6097

Please sign in to comment.