diff --git a/js/common/MoleculesAndLightA11yStrings.js b/js/common/MoleculesAndLightA11yStrings.js
index 2803072d..c79d257c 100644
--- a/js/common/MoleculesAndLightA11yStrings.js
+++ b/js/common/MoleculesAndLightA11yStrings.js
@@ -12,7 +12,7 @@ define( require => {
const moleculesAndLight = require( 'MOLECULES_AND_LIGHT/moleculesAndLight' );
- var MoleculesAndLightA11yStrings = {
+ const MoleculesAndLightA11yStrings = {
screenSummaryString: {
value: 'This sim has a Play Area and Control Area.' +
@@ -119,7 +119,7 @@ define( require => {
};
if ( phet.chipper.queryParameters.stringTest === 'xss' ) {
- for ( var key in MoleculesAndLightA11yStrings ) {
+ for ( const key in MoleculesAndLightA11yStrings ) {
MoleculesAndLightA11yStrings[ key ].value += '';
}
}
diff --git a/js/molecules-and-light-main.js b/js/molecules-and-light-main.js
index 0ac29f2b..e5764f4c 100644
--- a/js/molecules-and-light-main.js
+++ b/js/molecules-and-light-main.js
@@ -19,9 +19,9 @@ define( require => {
// strings
const moleculesAndLightTitleString = require( 'string!MOLECULES_AND_LIGHT/molecules-and-light.title' );
- var keyboardHelpContent = new MoleculesAndLightKeyboardHelpContent();
+ const keyboardHelpContent = new MoleculesAndLightKeyboardHelpContent();
- var simOptions = {
+ const simOptions = {
keyboardHelpNode: keyboardHelpContent,
credits: {
@@ -39,7 +39,7 @@ define( require => {
}
SimLauncher.launch( function() {
- var sim = new Sim( moleculesAndLightTitleString, [
+ const sim = new Sim( moleculesAndLightTitleString, [
new MoleculesAndLightScreen( Tandem.rootTandem.createTandem( 'moleculesAndLightScreen' ) )
], simOptions );
sim.start();
diff --git a/js/moleculesandlight/view/LightSpectrumDialog.js b/js/moleculesandlight/view/LightSpectrumDialog.js
index 3159d745..c7bb6271 100644
--- a/js/moleculesandlight/view/LightSpectrumDialog.js
+++ b/js/moleculesandlight/view/LightSpectrumDialog.js
@@ -21,7 +21,7 @@ define( require => {
const MoleculesAndLightA11yStrings = require( 'MOLECULES_AND_LIGHT/common/MoleculesAndLightA11yStrings' );
// a11y string
- var spectrumWindowDescriptionString = MoleculesAndLightA11yStrings.spectrumWindowDescriptionString.value;
+ const spectrumWindowDescriptionString = MoleculesAndLightA11yStrings.spectrumWindowDescriptionString.value;
/**
* @constructor
diff --git a/js/moleculesandlight/view/MoleculeSelectionPanel.js b/js/moleculesandlight/view/MoleculeSelectionPanel.js
index 0e6de87c..d1740c72 100644
--- a/js/moleculesandlight/view/MoleculeSelectionPanel.js
+++ b/js/moleculesandlight/view/MoleculeSelectionPanel.js
@@ -41,39 +41,39 @@ define( require => {
const molecularNamePatternString = require( 'string!MOLECULES_AND_LIGHT/molecularNamePattern' );
// a11y strings
- var moleculesString = MoleculesAndLightA11yStrings.moleculesString.value;
- var moleculesPanelDescriptionString = MoleculesAndLightA11yStrings.moleculesPanelDescriptionString.value;
- var nitrogenDescriptionString = MoleculesAndLightA11yStrings.nitrogenDescriptionString.value;
- var oxygenDescriptionString = MoleculesAndLightA11yStrings.oxygenDescriptionString.value;
- var carbonMonoxideDescriptionString = MoleculesAndLightA11yStrings.carbonMonoxideDescriptionString.value;
- var carbonDioxideDescriptionString = MoleculesAndLightA11yStrings.carbonDioxideDescriptionString.value;
- var methaneDescriptionString = MoleculesAndLightA11yStrings.methane;
- var waterDescriptionString = MoleculesAndLightA11yStrings.waterDescriptionString.value;
- var nitrogenDioxideDescriptionString = MoleculesAndLightA11yStrings.nitrogenDioxideDescriptionString.value;
- var ozoneDescriptionString = MoleculesAndLightA11yStrings.ozoneDescriptionString.value;
- var moleculeSelectionAlertPatternString = MoleculesAndLightA11yStrings.moleculeSelectionAlertPatternString.value;
+ const moleculesString = MoleculesAndLightA11yStrings.moleculesString.value;
+ const moleculesPanelDescriptionString = MoleculesAndLightA11yStrings.moleculesPanelDescriptionString.value;
+ const nitrogenDescriptionString = MoleculesAndLightA11yStrings.nitrogenDescriptionString.value;
+ const oxygenDescriptionString = MoleculesAndLightA11yStrings.oxygenDescriptionString.value;
+ const carbonMonoxideDescriptionString = MoleculesAndLightA11yStrings.carbonMonoxideDescriptionString.value;
+ const carbonDioxideDescriptionString = MoleculesAndLightA11yStrings.carbonDioxideDescriptionString.value;
+ const methaneDescriptionString = MoleculesAndLightA11yStrings.methane;
+ const waterDescriptionString = MoleculesAndLightA11yStrings.waterDescriptionString.value;
+ const nitrogenDioxideDescriptionString = MoleculesAndLightA11yStrings.nitrogenDioxideDescriptionString.value;
+ const ozoneDescriptionString = MoleculesAndLightA11yStrings.ozoneDescriptionString.value;
+ const moleculeSelectionAlertPatternString = MoleculesAndLightA11yStrings.moleculeSelectionAlertPatternString.value;
// constants
// Model view transform used for creating images of the various molecules. This is basically a null transform except
// that it scales down the size of the molecules and flips the Y axis so that molecules on the panel are oriented the
// same as in the play area.
- var MODEL_VIEW_TRANSFORM = ModelViewTransform2.createSinglePointScaleInvertedYMapping( new Vector2( 0, 0 ), new Vector2( 0, 0 ), 1 );
+ const MODEL_VIEW_TRANSFORM = ModelViewTransform2.createSinglePointScaleInvertedYMapping( new Vector2( 0, 0 ), new Vector2( 0, 0 ), 1 );
// Chemical formulas for the button labels.
- var CO_FORMULA_STRING = 'CO';
- var N2_FORMULA_STRING = ChemUtils.toSubscript( 'N2' );
- var O2_FORMULA_STRING = ChemUtils.toSubscript( 'O2' );
- var CO2_FORMULA_STRING = ChemUtils.toSubscript( 'CO2' );
- var NO2_FORMULA_STRING = ChemUtils.toSubscript( 'NO2' );
- var O3_FORMULA_STRING = ChemUtils.toSubscript( 'O3' );
- var H20_FORMULA_STRING = ChemUtils.toSubscript( 'H2O' );
- var CH4_FORMULA_STRING = ChemUtils.toSubscript( 'CH4' );
+ const CO_FORMULA_STRING = 'CO';
+ const N2_FORMULA_STRING = ChemUtils.toSubscript( 'N2' );
+ const O2_FORMULA_STRING = ChemUtils.toSubscript( 'O2' );
+ const CO2_FORMULA_STRING = ChemUtils.toSubscript( 'CO2' );
+ const NO2_FORMULA_STRING = ChemUtils.toSubscript( 'NO2' );
+ const O3_FORMULA_STRING = ChemUtils.toSubscript( 'O3' );
+ const H20_FORMULA_STRING = ChemUtils.toSubscript( 'H2O' );
+ const CH4_FORMULA_STRING = ChemUtils.toSubscript( 'CH4' );
// Scaling factor for the molecule images, determined empirically.
- var MOLECULE_SCALING_FACTOR = 0.0975;
+ const MOLECULE_SCALING_FACTOR = 0.0975;
// the focus highlights are a little larger so they look good in this rounded panel
- var HIGHLIGHT_DILATION = 1.5;
+ const HIGHLIGHT_DILATION = 1.5;
/**
@@ -85,12 +85,12 @@ define( require => {
*/
function MoleculeSelectionPanel( model, tandem ) {
- var scaleFactor = 1; // Scale factor of the text in this control panel. Value gets updated as panels are created.
+ let scaleFactor = 1; // Scale factor of the text in this control panel. Value gets updated as panels are created.
// Array which holds the formatted text of the control panel. This will get populated as individual panels are
// created. Storing the text allows us to call on it later for scaling purposes once the scale factor has been
// calculated.
- var textList = [];
+ const textList = [];
// Function which creates individual panels of the control panel. Each panel consists of a molecule name, chemical
// formula, and a visual node representing the molecule.
@@ -99,11 +99,11 @@ define( require => {
// Create a rectangle which holds the molecular name and representing node. Rectangle enables the proper layout
// which is the molecular name aligned to the left of the panel and the molecule node aligned to the right.
- var backgroundRectangle = new Rectangle( 0, 0, 215, 0 );
+ const backgroundRectangle = new Rectangle( 0, 0, 215, 0 );
// Create text label for the molecule name. Use StringUtils to order chemical names and formulas as desired.
- var moleculeNameString = StringUtils.format( molecularNamePatternString, moleculeName, '' + moleculeFormula + '' );
- var molecularName = new RichText( moleculeNameString, { fill: 'white', font: new PhetFont( 13 ) } );
+ const moleculeNameString = StringUtils.format( molecularNamePatternString, moleculeName, '' + moleculeFormula + '' );
+ const molecularName = new RichText( moleculeNameString, { fill: 'white', font: new PhetFont( 13 ) } );
textList.push( molecularName );
molecularName.centerY = backgroundRectangle.centerY;
molecularName.left = backgroundRectangle.left + 10;
@@ -114,7 +114,7 @@ define( require => {
moleculeNode.centerY = backgroundRectangle.centerY;
// Determine the scale factor for the text on this panel, primarily for translation.
- var nameIconDistance = 35; // Minimum distance between the molecule name and node, determined empirically.
+ const nameIconDistance = 35; // Minimum distance between the molecule name and node, determined empirically.
scaleFactor = Math.min( scaleFactor, ( moleculeNode.left - nameIconDistance ) / molecularName.width );
// Add the molecular name and molecule node to the selector panel.
@@ -125,7 +125,7 @@ define( require => {
}
- var createElement = function( photonTarget, formulaString, molecule, tandemName, descriptionContent ) {
+ const createElement = function( photonTarget, formulaString, molecule, tandemName, descriptionContent ) {
return {
node: createRadioButtonContent( PhotonTarget.getMoleculeName( photonTarget ),
formulaString, new MoleculeNode( molecule, MODEL_VIEW_TRANSFORM ) ),
@@ -135,10 +135,10 @@ define( require => {
descriptionContent: descriptionContent
};
};
- var moleculeOptions = { isForIcon: true };
+ const moleculeOptions = { isForIcon: true };
// Load the radio button content into an array of object literals which holds the node and value for each button.
- var radioButtonContent = [
+ const radioButtonContent = [
createElement( PhotonTarget.SINGLE_CO_MOLECULE, CO_FORMULA_STRING, new CO( moleculeOptions ),
'singleCOMoleculeRadioButton', carbonMonoxideDescriptionString ),
createElement( PhotonTarget.SINGLE_N2_MOLECULE, N2_FORMULA_STRING, new N2( moleculeOptions ),
@@ -162,7 +162,7 @@ define( require => {
_.each( textList, function( text ) { text.scale( scaleFactor ); } );
}
- var radioButtons = new RadioButtonGroup( model.photonTargetProperty, radioButtonContent, {
+ const radioButtons = new RadioButtonGroup( model.photonTargetProperty, radioButtonContent, {
spacing: 1.75,
baseColor: 'black',
buttonContentXMargin: 0,
@@ -181,7 +181,7 @@ define( require => {
} );
// custom group focus highlight so there is enough spacing between button highlight and group highlight
- var groupCoefficient = FocusHighlightPath.getGroupDilationCoefficient( radioButtons ) + HIGHLIGHT_DILATION;
+ const groupCoefficient = FocusHighlightPath.getGroupDilationCoefficient( radioButtons ) + HIGHLIGHT_DILATION;
radioButtons.groupFocusHighlight = new FocusHighlightPath( Shape.bounds( radioButtons.bounds.dilated( groupCoefficient ) ), {
outerLineWidth: FocusHighlightPath.GROUP_OUTER_LINE_WIDTH,
innerLineWidth: FocusHighlightPath.GROUP_INNER_LINE_WIDTH,
@@ -210,8 +210,8 @@ define( require => {
/**
* @param {PhotonTarget} target
*/
- var moleculeChangeAlert = function( target ) {
- var utteranceText = StringUtils.fillIn( moleculeSelectionAlertPatternString, { target: PhotonTarget.getMoleculeName( target ) } );
+ const moleculeChangeAlert = function( target ) {
+ const utteranceText = StringUtils.fillIn( moleculeSelectionAlertPatternString, { target: PhotonTarget.getMoleculeName( target ) } );
utteranceQueue.addToBack( utteranceText );
};
diff --git a/js/moleculesandlight/view/MoleculesAndLightScreenView.js b/js/moleculesandlight/view/MoleculesAndLightScreenView.js
index 8cfbd11c..4491f89c 100644
--- a/js/moleculesandlight/view/MoleculesAndLightScreenView.js
+++ b/js/moleculesandlight/view/MoleculesAndLightScreenView.js
@@ -40,27 +40,27 @@ define( require => {
const spectrumWindowButtonCaptionString = require( 'string!MOLECULES_AND_LIGHT/SpectrumWindow.buttonCaption' );
// a11y strings
- var spectrumButtonLabelString = MoleculesAndLightA11yStrings.spectrumButtonLabelString.value;
- var spectrumButtonDescriptionString = MoleculesAndLightA11yStrings.spectrumButtonDescriptionString.value;
- var screenSummaryString = MoleculesAndLightA11yStrings.screenSummaryString.value;
- var summaryInteractionHintString = MoleculesAndLightA11yStrings.summaryInteractionHintString.value;
- var playDescriptionString = MoleculesAndLightA11yStrings.playDescriptionString.value;
- var pauseDescriptionString = MoleculesAndLightA11yStrings.pauseDescriptionString.value;
- var stepButtonLabelString = MoleculesAndLightA11yStrings.stepButtonLabelString.value;
- var stepButtonDescriptionString = MoleculesAndLightA11yStrings.stepButtonDescriptionString.value;
+ const spectrumButtonLabelString = MoleculesAndLightA11yStrings.spectrumButtonLabelString.value;
+ const spectrumButtonDescriptionString = MoleculesAndLightA11yStrings.spectrumButtonDescriptionString.value;
+ const screenSummaryString = MoleculesAndLightA11yStrings.screenSummaryString.value;
+ const summaryInteractionHintString = MoleculesAndLightA11yStrings.summaryInteractionHintString.value;
+ const playDescriptionString = MoleculesAndLightA11yStrings.playDescriptionString.value;
+ const pauseDescriptionString = MoleculesAndLightA11yStrings.pauseDescriptionString.value;
+ const stepButtonLabelString = MoleculesAndLightA11yStrings.stepButtonLabelString.value;
+ const stepButtonDescriptionString = MoleculesAndLightA11yStrings.stepButtonDescriptionString.value;
// constants
// Model-view transform for intermediate coordinates.
- var INTERMEDIATE_RENDERING_SIZE = new Dimension2( 500, 300 );
+ const INTERMEDIATE_RENDERING_SIZE = new Dimension2( 500, 300 );
// Location of the top left corner of the observation window.
- var OBSERVATION_WINDOW_LOCATION = new Vector2( 15, 15 );
+ const OBSERVATION_WINDOW_LOCATION = new Vector2( 15, 15 );
// Corner radius of the observation window.
- var CORNER_RADIUS = 7;
+ const CORNER_RADIUS = 7;
// Line width of the observation window frame
- var FRAME_LINE_WIDTH = 5;
+ const FRAME_LINE_WIDTH = 5;
/**
* Constructor for the screen view of Molecules and Light.
@@ -71,7 +71,7 @@ define( require => {
*/
function MoleculesAndLightScreenView( photonAbsorptionModel, tandem ) {
- var summaryNode = new Node( {
+ const summaryNode = new Node( {
tagName: 'p',
accessibleName: screenSummaryString
} );
@@ -85,7 +85,7 @@ define( require => {
// interaction hint and keyboard shortcuts
summaryNode.addChild( new Node( { tagName: 'p', innerContent: summaryInteractionHintString } ) );
- var modelViewTransform = ModelViewTransform2.createSinglePointScaleInvertedYMapping(
+ const modelViewTransform = ModelViewTransform2.createSinglePointScaleInvertedYMapping(
Vector2.ZERO,
new Vector2( Util.roundSymmetric( INTERMEDIATE_RENDERING_SIZE.width * 0.55 ),
Util.roundSymmetric( INTERMEDIATE_RENDERING_SIZE.height * 0.50 ) ),
@@ -93,14 +93,14 @@ define( require => {
// Create the observation window. This will hold all photons, molecules, and photonEmitters for this photon
// absorption model.
- var observationWindow = new ObservationWindow( photonAbsorptionModel, modelViewTransform, tandem.createTandem( 'observationWindow' ) );
+ const observationWindow = new ObservationWindow( photonAbsorptionModel, modelViewTransform, tandem.createTandem( 'observationWindow' ) );
this.playAreaNode.addChild( observationWindow );
// This rectangle hides photons that are outside the observation window.
// TODO: This rectangle is a temporary workaround that replaces the clipping area in ObservationWindow because of a
// Safari specific SVG bug caused by clipping. See https://github.com/phetsims/molecules-and-light/issues/105 and
// https://github.com/phetsims/scenery/issues/412.
- var clipRectangle = new Rectangle( observationWindow.bounds.copy().dilate( 4 * FRAME_LINE_WIDTH ),
+ const clipRectangle = new Rectangle( observationWindow.bounds.copy().dilate( 4 * FRAME_LINE_WIDTH ),
CORNER_RADIUS, CORNER_RADIUS, {
stroke: '#C5D6E8',
lineWidth: 8 * FRAME_LINE_WIDTH
@@ -108,7 +108,7 @@ define( require => {
this.playAreaNode.addChild( clipRectangle );
// Create the window frame node that borders the observation window.
- var windowFrameNode = new WindowFrameNode( observationWindow, '#BED0E7', '#4070CE' );
+ const windowFrameNode = new WindowFrameNode( observationWindow, '#BED0E7', '#4070CE' );
this.playAreaNode.addChild( windowFrameNode );
// Set positions of the observation window and window frame.
@@ -117,15 +117,15 @@ define( require => {
windowFrameNode.translate( OBSERVATION_WINDOW_LOCATION );
// Create the control panel for photon emission frequency.
- var photonEmissionControlPanel = new QuadEmissionFrequencyControlPanel( photonAbsorptionModel, tandem.createTandem( 'photonEmissionControlPanel' ) );
+ const photonEmissionControlPanel = new QuadEmissionFrequencyControlPanel( photonAbsorptionModel, tandem.createTandem( 'photonEmissionControlPanel' ) );
photonEmissionControlPanel.leftTop = ( new Vector2( OBSERVATION_WINDOW_LOCATION.x, 350 ) );
// Create the molecule control panel
- var moleculeControlPanel = new MoleculeSelectionPanel( photonAbsorptionModel, tandem.createTandem( 'moleculeControlPanel' ) );
+ const moleculeControlPanel = new MoleculeSelectionPanel( photonAbsorptionModel, tandem.createTandem( 'moleculeControlPanel' ) );
moleculeControlPanel.leftTop = ( new Vector2( 530, windowFrameNode.top ) );
// Add reset all button.
- var resetAllButton = new ResetAllButton( {
+ const resetAllButton = new ResetAllButton( {
listener: function() { photonAbsorptionModel.reset(); },
bottom: this.layoutBounds.bottom - 15,
right: this.layoutBounds.right - 15,
@@ -135,7 +135,7 @@ define( require => {
this.controlAreaNode.addChild( resetAllButton );
// Add play/pause button.
- var playPauseButton = new PlayPauseButton( photonAbsorptionModel.runningProperty, {
+ const playPauseButton = new PlayPauseButton( photonAbsorptionModel.runningProperty, {
bottom: moleculeControlPanel.bottom + 60,
centerX: moleculeControlPanel.centerX - 25,
radius: 23,
@@ -149,7 +149,7 @@ define( require => {
this.controlAreaNode.addChild( playPauseButton );
// Add step button to manually step the animation.
- var stepButton = new StepForwardButton( {
+ const stepButton = new StepForwardButton( {
isPlayingProperty: photonAbsorptionModel.runningProperty,
listener: function() { photonAbsorptionModel.manualStep(); },
centerY: playPauseButton.centerY,
@@ -168,15 +168,15 @@ define( require => {
// Content for the window that displays the EM spectrum upon request. Constructed once here so that time is not
// waisted drawing a new spectrum window every time the user presses the 'Show Light Spectrum' button.
// @private
- var spectrumButtonLabel = new SpectrumDiagram( tandem.createTandem( 'spectrumButtonLabel' ) );
+ const spectrumButtonLabel = new SpectrumDiagram( tandem.createTandem( 'spectrumButtonLabel' ) );
// the spectrum dialog, created lazily because Dialog requires sim bounds during construction
- var dialog = null;
+ let dialog = null;
// Add the button for displaying the electromagnetic spectrum. Scale down the button content when it gets too
// large. This is done to support translations. Max width of this button is the width of the molecule control
// panel minus twice the default x margin of a rectangular push button.
- var buttonContent = new Text( spectrumWindowButtonCaptionString, { font: new PhetFont( 18 ) } );
+ const buttonContent = new Text( spectrumWindowButtonCaptionString, { font: new PhetFont( 18 ) } );
if ( buttonContent.width > moleculeControlPanel.width - 16 ) {
buttonContent.scale( ( moleculeControlPanel.width - 16 ) / buttonContent.width );
}
diff --git a/js/moleculesandlight/view/ObservationWindow.js b/js/moleculesandlight/view/ObservationWindow.js
index 87007eef..f7dca232 100644
--- a/js/moleculesandlight/view/ObservationWindow.js
+++ b/js/moleculesandlight/view/ObservationWindow.js
@@ -35,18 +35,18 @@ define( require => {
const buttonNodeReturnMoleculeString = require( 'string!MOLECULES_AND_LIGHT/ButtonNode.ReturnMolecule' );
// a11y strings
- var observationWindowDescriptionPatternString = MoleculesAndLightA11yStrings.observationWindowDescriptionPatternString.value;
- var isOffAndPointsString = MoleculesAndLightA11yStrings.isOffAndPointsString.value;
- var emitsPhotonsString = MoleculesAndLightA11yStrings.emitsPhotonsString.value;
- var aString = MoleculesAndLightA11yStrings.aString.value;
- var anString = MoleculesAndLightA11yStrings.anString.value;
- var returnMoleculeString = MoleculesAndLightA11yStrings.returnMoleculeString.value;
- var returnMoleculeHelpString = MoleculesAndLightA11yStrings.returnMoleculeHelpString.value;
+ const observationWindowDescriptionPatternString = MoleculesAndLightA11yStrings.observationWindowDescriptionPatternString.value;
+ const isOffAndPointsString = MoleculesAndLightA11yStrings.isOffAndPointsString.value;
+ const emitsPhotonsString = MoleculesAndLightA11yStrings.emitsPhotonsString.value;
+ const aString = MoleculesAndLightA11yStrings.aString.value;
+ const anString = MoleculesAndLightA11yStrings.anString.value;
+ const returnMoleculeString = MoleculesAndLightA11yStrings.returnMoleculeString.value;
+ const returnMoleculeHelpString = MoleculesAndLightA11yStrings.returnMoleculeHelpString.value;
// constants
- var PHOTON_EMITTER_WIDTH = 125;
- var CORNER_RADIUS = 7;
+ const PHOTON_EMITTER_WIDTH = 125;
+ const CORNER_RADIUS = 7;
/**
* Constructor for a Molecules and Light observation window.
@@ -68,7 +68,7 @@ define( require => {
labelContent: 'Observation Window'
} );
- var self = this;
+ const self = this;
this.modelViewTransform = modelViewTransform; // @private
this.photonAbsorptionModel = photonAbsorptionModel; // @private
@@ -81,13 +81,13 @@ define( require => {
} ); // @private
// Add the layers for molecules, photons, and photon emitters.
- var moleculeLayer = new Node();
+ const moleculeLayer = new Node();
this.addChild( moleculeLayer );
- var photonLayer = new Node();
+ const photonLayer = new Node();
this.addChild( photonLayer );
- var photonEmitterLayer = new Node();
+ const photonEmitterLayer = new Node();
this.addChild( photonEmitterLayer );
// if using Edge, render the photon layer and emitter with SVG for improved performance, see #175
@@ -97,7 +97,7 @@ define( require => {
}
// Create and add the photon emitter.
- var photonEmitterNode = new PhotonEmitterNode( PHOTON_EMITTER_WIDTH, photonAbsorptionModel, tandem.createTandem( 'photonEmitterNode' ) );
+ const photonEmitterNode = new PhotonEmitterNode( PHOTON_EMITTER_WIDTH, photonAbsorptionModel, tandem.createTandem( 'photonEmitterNode' ) );
photonEmitterNode.center = ( modelViewTransform.modelToViewPosition( photonAbsorptionModel.getPhotonEmissionLocation() ) );
photonEmitterLayer.addChild( photonEmitterNode );
@@ -118,10 +118,10 @@ define( require => {
this.particleRemovalBounds = this.bounds.copy().dilate( 20 ); // @private
// Add the button for restoring molecules that break apart.
- var buttonContent = new Text( buttonNodeReturnMoleculeString, { font: new PhetFont( 13 ) } );
+ const buttonContent = new Text( buttonNodeReturnMoleculeString, { font: new PhetFont( 13 ) } );
// If necessary, scale the button content for translation purposes. Max button width is half the width of the
// observation window.
- var maxButtonWidth = this.width / 2;
+ const maxButtonWidth = this.width / 2;
if ( buttonContent.width > maxButtonWidth ) {
buttonContent.scale( maxButtonWidth / buttonContent.width );
}
@@ -155,11 +155,11 @@ define( require => {
// function for adding a molecule to this window and hooking up a removal listener
function addMoleculeToWindow( molecule ) {
- var moleculeNode = new MoleculeNode( molecule, self.modelViewTransform ); //Create the molecule node.
+ const moleculeNode = new MoleculeNode( molecule, self.modelViewTransform ); //Create the molecule node.
moleculeLayer.addChild( moleculeNode );
// Determine if it is time to remove molecule and update restore molecule button visibility.
- var centerOfGravityObserver = function() {
+ const centerOfGravityObserver = function() {
self.moleculeCheckBounds();
};
molecule.centerOfGravityProperty.link( centerOfGravityObserver );
@@ -181,11 +181,11 @@ define( require => {
// Set up the event listeners for adding and removing photons.
photonAbsorptionModel.photons.addItemAddedListener( function( addedPhoton ) {
- var photonNode = new PhotonNode( addedPhoton, self.modelViewTransform );
+ const photonNode = new PhotonNode( addedPhoton, self.modelViewTransform );
photonLayer.addChild( photonNode );
// Watch photon positions and determine if photon should be removed from window.
- var photonPositionObserver = function() {
+ const photonPositionObserver = function() {
self.photonCheckBounds();
};
addedPhoton.locationProperty.link( photonPositionObserver );
@@ -226,8 +226,8 @@ define( require => {
*/
moleculeCheckBounds: function() {
- var moleculesToRemove = [];
- for ( var molecule = 0; molecule < this.photonAbsorptionModel.activeMolecules.length; molecule++ ) {
+ const moleculesToRemove = [];
+ for ( let molecule = 0; molecule < this.photonAbsorptionModel.activeMolecules.length; molecule++ ) {
if ( !this.particleRemovalBounds.containsPoint( this.modelViewTransform.modelToViewPosition( this.photonAbsorptionModel.activeMolecules.get( molecule ).getCenterOfGravityPos() ) ) ) {
moleculesToRemove.push( this.photonAbsorptionModel.activeMolecules.get( molecule ) );
this.returnMoleculeButtonVisibleProperty.set( true );
@@ -244,8 +244,8 @@ define( require => {
*/
photonCheckBounds: function() {
- var photonsToRemove = [];
- for ( var photon = 0; photon < this.photonAbsorptionModel.photons.length; photon++ ) {
+ const photonsToRemove = [];
+ for ( let photon = 0; photon < this.photonAbsorptionModel.photons.length; photon++ ) {
if ( !this.particleRemovalBounds.containsPoint( this.modelViewTransform.modelToViewPosition( this.photonAbsorptionModel.photons.get( photon ).locationProperty.get() ) ) ) {
photonsToRemove.push( this.photonAbsorptionModel.photons.get( photon ) );
}
@@ -253,7 +253,7 @@ define( require => {
this.photonAbsorptionModel.photons.removeAll( photonsToRemove );
// dispose all photons that leave the observation window
- for ( var i = 0; i < photonsToRemove.length; i++ ) {
+ for ( let i = 0; i < photonsToRemove.length; i++ ) {
photonsToRemove[ i ].dispose();
}
},
@@ -267,10 +267,10 @@ define( require => {
updateAccessibleDescription: function( photonTarget, emissionFrequency, wavelength ) {
- var lightSourceString = WavelengthConstants.getLightSourceName( wavelength );
- var moleculeString = PhotonTarget.getMoleculeName( photonTarget );
- var onOfString = emissionFrequency > 0 ? emitsPhotonsString : isOffAndPointsString;
- var aOrAn = 'AEIOU'.search( moleculeString.charAt( 1 ) ) === -1 ? aString : anString;
+ const lightSourceString = WavelengthConstants.getLightSourceName( wavelength );
+ const moleculeString = PhotonTarget.getMoleculeName( photonTarget );
+ const onOfString = emissionFrequency > 0 ? emitsPhotonsString : isOffAndPointsString;
+ const aOrAn = 'AEIOU'.search( moleculeString.charAt( 1 ) ) === -1 ? aString : anString;
this.descriptionContent = StringUtils.fillIn( observationWindowDescriptionPatternString, {
wavelengthName: lightSourceString,
diff --git a/js/moleculesandlight/view/QuadEmissionFrequencyControlPanel.js b/js/moleculesandlight/view/QuadEmissionFrequencyControlPanel.js
index 21dc3ba5..bf97ffe1 100644
--- a/js/moleculesandlight/view/QuadEmissionFrequencyControlPanel.js
+++ b/js/moleculesandlight/view/QuadEmissionFrequencyControlPanel.js
@@ -44,16 +44,16 @@ define( require => {
const quadWavelengthSelectorVisibleString = require( 'string!MOLECULES_AND_LIGHT/QuadWavelengthSelector.Visible' );
// a11y strings
- var lightSourceString = MoleculesAndLightA11yStrings.lightSourceString.value;
- var lightSourceDescriptionString = MoleculesAndLightA11yStrings.lightSourceDescriptionString.value;
- var wavelengthSelectionAlertPatternString = MoleculesAndLightA11yStrings.wavelengthSelectionAlertPatternString.value;
+ const lightSourceString = MoleculesAndLightA11yStrings.lightSourceString.value;
+ const lightSourceDescriptionString = MoleculesAndLightA11yStrings.lightSourceDescriptionString.value;
+ const wavelengthSelectionAlertPatternString = MoleculesAndLightA11yStrings.wavelengthSelectionAlertPatternString.value;
// Description data for the 'Energy Arrow'
- var ARROW_LENGTH = 200;
- var ARROW_HEAD_HEIGHT = 15;
- var ARROW_HEAD_WIDTH = 20;
- var ARROW_TAIL_WIDTH = 1;
- var ARROW_COLOR = 'black';
+ const ARROW_LENGTH = 200;
+ const ARROW_HEAD_HEIGHT = 15;
+ const ARROW_HEAD_WIDTH = 20;
+ const ARROW_TAIL_WIDTH = 1;
+ const ARROW_COLOR = 'black';
// Create a layout box which holds a single panel of this control panel.
function createRadioButtonContent( emitterImage, photonNode ) {
@@ -80,35 +80,35 @@ define( require => {
// Initialize the photon nodes for the control panel. Identity model view transform is used because these photon
// nodes do not correspond to anything in the model. They are just visual elements of the control panel.
- var identityTransform = ModelViewTransform2.createIdentity();
- var microwavePhotonNode = new PhotonNode(
+ const identityTransform = ModelViewTransform2.createIdentity();
+ const microwavePhotonNode = new PhotonNode(
new Photon( WavelengthConstants.MICRO_WAVELENGTH, tandem.createTandem( 'microwavePhotonNode' ) ),
identityTransform
);
- var infraredPhotonNode = new PhotonNode(
+ const infraredPhotonNode = new PhotonNode(
new Photon( WavelengthConstants.IR_WAVELENGTH, tandem.createTandem( 'infraredPhotonNode' ) ),
identityTransform
);
- var visiblePhotonNode = new PhotonNode(
+ const visiblePhotonNode = new PhotonNode(
new Photon( WavelengthConstants.VISIBLE_WAVELENGTH, tandem.createTandem( 'visiblePhotonNode' ) ),
identityTransform
);
- var ultravioletPhotonNode = new PhotonNode(
+ const ultravioletPhotonNode = new PhotonNode(
new Photon( WavelengthConstants.UV_WAVELENGTH, tandem.createTandem( 'ultravioletPhotonNode' ) ),
identityTransform
);
// Load the radio button content into an array of object literals which holds the node, label string, and
// value for each button.
- var labelFont = new PhetFont( 18 );
+ const labelFont = new PhetFont( 18 );
// This is sort of hack to pass through the tandem of the radioButtonGroupMember to its child.
- var microwaveTandemName = 'microwaveRadioButton';
- var infraredTandemName = 'infraredRadioButton';
- var visibleTandemName = 'visibleRadioButton';
- var ultravioletTandemName = 'ultravioletRadioButton';
- var radioButtonGroupTandem = tandem.createTandem( 'radioButtonGroup' );
- var radioButtonContent = [ {
+ const microwaveTandemName = 'microwaveRadioButton';
+ const infraredTandemName = 'infraredRadioButton';
+ const visibleTandemName = 'visibleRadioButton';
+ const ultravioletTandemName = 'ultravioletRadioButton';
+ const radioButtonGroupTandem = tandem.createTandem( 'radioButtonGroup' );
+ const radioButtonContent = [ {
node: createRadioButtonContent( new Image( microwaveTransmitter ), microwavePhotonNode ),
value: WavelengthConstants.MICRO_WAVELENGTH,
label: new Text( quadWavelengthSelectorMicrowaveString, {
@@ -148,11 +148,11 @@ define( require => {
// Scale the radio button text. This is done mostly to support translations.
// Determine the max width of panels in the radio button group.
- var panelWidth = _.maxBy( radioButtonContent, function( content ) { return content.node.width; } ).node.width;
+ const panelWidth = _.maxBy( radioButtonContent, function( content ) { return content.node.width; } ).node.width;
// Calculate the minimum scale factor that must be applied to each label. Ensures constant font size for all labels.
- var scaleFactor = 1;
+ let scaleFactor = 1;
_.each( radioButtonContent, function( content ) {
- var labelWidth = content.label.width;
+ const labelWidth = content.label.width;
scaleFactor = Math.min( scaleFactor, panelWidth / labelWidth );
} );
// If necessary, scale down each label by the minimum scale value.
@@ -162,7 +162,7 @@ define( require => {
} );
}
- var radioButtons = new RadioButtonGroup( photonAbsorptionModel.photonWavelengthProperty, radioButtonContent, {
+ const radioButtons = new RadioButtonGroup( photonAbsorptionModel.photonWavelengthProperty, radioButtonContent, {
orientation: 'horizontal',
spacing: 15,
baseColor: 'black',
@@ -176,8 +176,8 @@ define( require => {
} );
// Draw an arrow node to illustrate energy of the emitted photons.
- var energyText = new Text( quadWavelengthSelectorHigherEnergyString, { font: new PhetFont( 19 ) } );
- var energyArrow = new ArrowNode( 0, 0, ARROW_LENGTH, 0, {
+ const energyText = new Text( quadWavelengthSelectorHigherEnergyString, { font: new PhetFont( 19 ) } );
+ const energyArrow = new ArrowNode( 0, 0, ARROW_LENGTH, 0, {
fill: ARROW_COLOR,
stroke: ARROW_COLOR,
headHeight: ARROW_HEAD_HEIGHT,
@@ -202,8 +202,8 @@ define( require => {
this.addChild( energyText );
// a11y - link alerts to the model's wavelength property
- var handleWavelengthChangeAlert = function( wavelength ) {
- var utteranceText = StringUtils.fillIn(
+ const handleWavelengthChangeAlert = function( wavelength ) {
+ const utteranceText = StringUtils.fillIn(
wavelengthSelectionAlertPatternString,
{ wavelength: WavelengthConstants.getLightSourceName( wavelength ) }
);
diff --git a/js/moleculesandlight/view/SpectrumDiagram.js b/js/moleculesandlight/view/SpectrumDiagram.js
index bf1896d5..f3d5e8a9 100644
--- a/js/moleculesandlight/view/SpectrumDiagram.js
+++ b/js/moleculesandlight/view/SpectrumDiagram.js
@@ -44,21 +44,21 @@ define( require => {
const spectrumWindowXrayBandLabelString = require( 'string!MOLECULES_AND_LIGHT/SpectrumWindow.xrayBandLabel' );
// shared constants
- var LABEL_FONT = new PhetFont( 16 );
- var SUBSECTION_WIDTH = 490; // width of each subsection on the window (arrows, chirp node, and labeled diagram).
- var MAX_UNITS_WIDTH = SUBSECTION_WIDTH / 10; // maximum width of units text, necessary for long translated units strings.
+ const LABEL_FONT = new PhetFont( 16 );
+ const SUBSECTION_WIDTH = 490; // width of each subsection on the window (arrows, chirp node, and labeled diagram).
+ const MAX_UNITS_WIDTH = SUBSECTION_WIDTH / 10; // maximum width of units text, necessary for long translated units strings.
// constants for LabeledSpectrumNode
- var STRIP_HEIGHT = 65;
- var MIN_FREQUENCY = 1E3;
- var MAX_FREQUENCY = 1E21;
- var TICK_MARK_HEIGHT = 8;
- var TICK_MARK_FONT = new PhetFont( 11 );
+ const STRIP_HEIGHT = 65;
+ const MIN_FREQUENCY = 1E3;
+ const MAX_FREQUENCY = 1E21;
+ const TICK_MARK_HEIGHT = 8;
+ const TICK_MARK_FONT = new PhetFont( 11 );
// constants for labeledArrow
- var ARROW_HEAD_HEIGHT = 40;
- var ARROW_HEAD_WIDTH = 40;
- var ARROW_TAIL_WIDTH = 25;
+ const ARROW_HEAD_HEIGHT = 40;
+ const ARROW_HEAD_WIDTH = 40;
+ const ARROW_TAIL_WIDTH = 25;
/**
* Class that contains the diagram of the EM spectrum. This class includes the arrows, the spectrum strip, the
@@ -69,17 +69,17 @@ define( require => {
*/
function SpectrumDiagram( tandem ) {
- var children = [];
+ const children = [];
// Add the title and scale for translations.
- var title = new Text( spectrumWindowTitleString, { font: new PhetFont( 30 ) } );
+ const title = new Text( spectrumWindowTitleString, { font: new PhetFont( 30 ) } );
if ( title.width > SUBSECTION_WIDTH ) {
title.scale( SUBSECTION_WIDTH / title.width );
}
children.push( title );
// Add the frequency arrow.
- var frequencyArrow = new LabeledArrow(
+ const frequencyArrow = new LabeledArrow(
SUBSECTION_WIDTH,
'right',
spectrumWindowFrequencyArrowLabelString,
@@ -90,11 +90,11 @@ define( require => {
children.push( frequencyArrow );
// Add the spectrum portion.
- var spectrum = new LabeledSpectrumNode( tandem.createTandem( 'spectrum' ) );
+ const spectrum = new LabeledSpectrumNode( tandem.createTandem( 'spectrum' ) );
children.push( spectrum );
// Add the wavelength arrow.
- var wavelengthArrow = new LabeledArrow(
+ const wavelengthArrow = new LabeledArrow(
SUBSECTION_WIDTH,
'left',
spectrumWindowWavelengthArrowLabelString,
@@ -105,7 +105,7 @@ define( require => {
children.push( wavelengthArrow );
// Add the diagram that depicts the wave that gets shorter.
- var decreasingWavelengthNode = new ChirpNode();
+ const decreasingWavelengthNode = new ChirpNode();
children.push( decreasingWavelengthNode );
LayoutBox.call( this, { orientation: 'vertical', children: children, spacing: 15 } );
@@ -132,13 +132,13 @@ define( require => {
*/
function LabeledArrow( length, orientation, captionText, leftColor, rightColor, tandem ) {
- var Orientation = {
+ const Orientation = {
POINTING_LEFT: 'left',
POINTING_RIGHT: 'right'
};
// Set arrow direction and fill based on desired orientation.
- var gradientPaint;
+ let gradientPaint;
// Point the node in the right direction.
if ( orientation === Orientation.POINTING_LEFT ) {
gradientPaint = new LinearGradient( 0, 0, -length, 0 ).addColorStop( 0, leftColor ).addColorStop( 1, rightColor );
@@ -160,7 +160,7 @@ define( require => {
// Create and add the textual label. Scale it so that it can handle translations. Max label length is the arrow
// length minus twice the head length.
- var label = new Text( captionText, { font: LABEL_FONT } );
+ const label = new Text( captionText, { font: LABEL_FONT } );
if ( label.width > this.width - 2 * ARROW_HEAD_WIDTH ) {
label.scale( (this.width - 2 * ARROW_HEAD_WIDTH) / label.width );
}
@@ -183,11 +183,11 @@ define( require => {
// Supertype constructor
Node.call( this );
- var self = this;
+ const self = this;
// Create the "strip", which is the solid background portions that contains the different bands and that has tick
// marks on the top and bottom.
- var strip = new Rectangle( 0, 0, SUBSECTION_WIDTH, STRIP_HEIGHT, {
+ const strip = new Rectangle( 0, 0, SUBSECTION_WIDTH, STRIP_HEIGHT, {
fill: 'rgb(237, 243, 246)',
lineWidth: 2,
stroke: 'black'
@@ -195,14 +195,14 @@ define( require => {
this.addChild( strip );
// Add the frequency tick marks to the top of the spectrum strip.
- for ( var i = 4; i <= 20; i++ ) {
- var includeFrequencyLabel = (i % 2 === 0);
+ for ( let i = 4; i <= 20; i++ ) {
+ const includeFrequencyLabel = (i % 2 === 0);
addFrequencyTickMark( self, Math.pow( 10, i ), strip.top, includeFrequencyLabel );
}
// Add the wavelength tick marks to the bottom of the spectrum.
- for ( var j = -12; j <= 4; j++ ) {
- var includeWavelengthLabel = (j % 2 === 0);
+ for ( let j = -12; j <= 4; j++ ) {
+ const includeWavelengthLabel = (j % 2 === 0);
addWavelengthTickMark( self, Math.pow( 10, j ), strip.bottom, includeWavelengthLabel );
}
@@ -219,15 +219,15 @@ define( require => {
addBandLabel( self, 1E19, 1E21, spectrumWindowGammaRayBandLabelString, tandem.createTandem( 'gammaRayBandLabel' ) );
// Add the visible spectrum.
- var visSpectrumWidth = Util.roundSymmetric( getOffsetFromFrequency( 790E12 ) - getOffsetFromFrequency( 400E12 ) );
- var wavelengthSpectrumNode = new WavelengthSpectrumNode( { size: new Dimension2( visSpectrumWidth, STRIP_HEIGHT - 2 ) } );
+ const visSpectrumWidth = Util.roundSymmetric( getOffsetFromFrequency( 790E12 ) - getOffsetFromFrequency( 400E12 ) );
+ const wavelengthSpectrumNode = new WavelengthSpectrumNode( { size: new Dimension2( visSpectrumWidth, STRIP_HEIGHT - 2 ) } );
wavelengthSpectrumNode.rotate( Math.PI ); // Flip the visible spectrum so that it is represented correctly in the diagram.
wavelengthSpectrumNode.leftTop = new Vector2( getOffsetFromFrequency( 400E12 ), strip.top + strip.lineWidth );
this.addChild( wavelengthSpectrumNode );
// Add the label for the visible band. Scale it down for translations.
- var visibleBandLabel = new Text( spectrumWindowVisibleBandLabelString, { font: new PhetFont( 12 ) } );
- var visibleBandCenterX = wavelengthSpectrumNode.centerX;
+ const visibleBandLabel = new Text( spectrumWindowVisibleBandLabelString, { font: new PhetFont( 12 ) } );
+ const visibleBandCenterX = wavelengthSpectrumNode.centerX;
if ( visibleBandLabel.width > strip.width / 2 ) {
visibleBandLabel.scale( (strip.width / 2) / visibleBandLabel.width );
}
@@ -235,7 +235,7 @@ define( require => {
this.addChild( visibleBandLabel );
// Add the arrow that connects the visible band label to the visible band itself.
- var visibleBandArrow = new ArrowNode( visibleBandCenterX, visibleBandLabel.bottom, visibleBandCenterX, -5, {
+ const visibleBandArrow = new ArrowNode( visibleBandCenterX, visibleBandLabel.bottom, visibleBandCenterX, -5, {
tailWidth: 2,
headWidth: 7,
headHeight: 7,
@@ -244,17 +244,17 @@ define( require => {
this.addChild( visibleBandArrow );
// Add the units and scale for translations
- var scaleUnits = function( text ) {
+ const scaleUnits = function( text ) {
if ( text.width > MAX_UNITS_WIDTH ) {
text.scale( MAX_UNITS_WIDTH / text.width );
}
};
- var frequencyUnits = new Text( spectrumWindowCyclesPerSecondUnitsString, { font: LABEL_FONT } );
+ const frequencyUnits = new Text( spectrumWindowCyclesPerSecondUnitsString, { font: LABEL_FONT } );
scaleUnits( frequencyUnits );
frequencyUnits.leftCenter = new Vector2( SUBSECTION_WIDTH, -TICK_MARK_HEIGHT - frequencyUnits.height / 2 );
this.addChild( frequencyUnits );
- var wavelengthUnits = new Text( spectrumWindowMetersUnitsString, { font: LABEL_FONT } );
+ const wavelengthUnits = new Text( spectrumWindowMetersUnitsString, { font: LABEL_FONT } );
scaleUnits( wavelengthUnits );
wavelengthUnits.leftCenter = new Vector2( SUBSECTION_WIDTH, STRIP_HEIGHT + TICK_MARK_HEIGHT + frequencyUnits.height / 2 );
this.addChild( wavelengthUnits );
@@ -271,8 +271,8 @@ define( require => {
*/
function getOffsetFromFrequency( frequency ) {
assert && assert( frequency >= MIN_FREQUENCY && frequency <= MAX_FREQUENCY );
- var logarithmicRange = log10( MAX_FREQUENCY ) - log10( MIN_FREQUENCY );
- var logarithmicFrequency = log10( frequency );
+ const logarithmicRange = log10( MAX_FREQUENCY ) - log10( MIN_FREQUENCY );
+ const logarithmicFrequency = log10( frequency );
return (logarithmicFrequency - log10( MIN_FREQUENCY )) / logarithmicRange * SUBSECTION_WIDTH;
}
@@ -284,7 +284,7 @@ define( require => {
*/
function createExponentialLabel( value ) {
- var superscript = Util.roundSymmetric( log10( value ) );
+ const superscript = Util.roundSymmetric( log10( value ) );
return new RichText( '10' + superscript + '', {
font: TICK_MARK_FONT,
supScale: 0.65,
@@ -324,15 +324,15 @@ define( require => {
*/
function addFrequencyTickMark( thisNode, frequency, bottom, addLabel ) {
// Create and add the tick mark line.
- var tickMarkNode = new Line( 0, 0, 0, -TICK_MARK_HEIGHT, { stroke: 'black', lineWidth: 2 } );
+ const tickMarkNode = new Line( 0, 0, 0, -TICK_MARK_HEIGHT, { stroke: 'black', lineWidth: 2 } );
tickMarkNode.centerBottom = new Vector2( getOffsetFromFrequency( frequency ), bottom );
thisNode.addChild( tickMarkNode );
if ( addLabel ) {
// Create and add the label.
- var label = createExponentialLabel( frequency );
+ const label = createExponentialLabel( frequency );
// Calculate x offset for label. Allows the base number of the label to centered with the tick mark.
- var xOffset = new Text( '10', { font: TICK_MARK_FONT } ).width / 2;
+ const xOffset = new Text( '10', { font: TICK_MARK_FONT } ).width / 2;
label.leftCenter = new Vector2( tickMarkNode.centerX - xOffset, tickMarkNode.top - label.height / 2 );
thisNode.addChild( label );
}
@@ -349,12 +349,12 @@ define( require => {
function addWavelengthTickMark( thisNode, wavelength, top, addLabel ) {
// Create and add the tick mark line.
- var tickMarkNode = new Line( 0, 0, 0, TICK_MARK_HEIGHT, { stroke: 'black', lineWidth: 2 } );
+ const tickMarkNode = new Line( 0, 0, 0, TICK_MARK_HEIGHT, { stroke: 'black', lineWidth: 2 } );
tickMarkNode.centerTop = new Vector2( getOffsetFromWavelength( wavelength ), top );
thisNode.addChild( tickMarkNode );
if ( addLabel ) {
// Create and add the label.
- var label = createExponentialLabel( wavelength );
+ const label = createExponentialLabel( wavelength );
// Calculate x offset for label. Allows the base number of the label to be centered with the tick mark.
label.center = new Vector2( tickMarkNode.centerX, tickMarkNode.top + label.height + 2 );
thisNode.addChild( label );
@@ -376,13 +376,13 @@ define( require => {
assert && assert( highEndFrequency >= lowEndFrequency );
// Set up values needed for calculations.
- var leftBoundaryX = getOffsetFromFrequency( lowEndFrequency );
- var rightBoundaryX = getOffsetFromFrequency( highEndFrequency );
- var width = rightBoundaryX - leftBoundaryX;
- var centerX = leftBoundaryX + width / 2;
+ const leftBoundaryX = getOffsetFromFrequency( lowEndFrequency );
+ const rightBoundaryX = getOffsetFromFrequency( highEndFrequency );
+ const width = rightBoundaryX - leftBoundaryX;
+ const centerX = leftBoundaryX + width / 2;
// Create and add the label.
- var labelText = new MultiLineText( labelString, { align: 'center', font: LABEL_FONT, tandem: tandem } );
+ const labelText = new MultiLineText( labelString, { align: 'center', font: LABEL_FONT, tandem: tandem } );
thisNode.addChild( labelText );
if ( (labelText.width + 10) > width ) {
@@ -400,14 +400,14 @@ define( require => {
* @param {number} frequency
*/
function addBandDivider( thisNode, frequency ) {
- var drawDividerSegment = function() {
+ const drawDividerSegment = function() {
return new Line( 0, 0, 0, STRIP_HEIGHT / 9, {
stroke: 'black',
lineWidth: 2
} );
};
- for ( var i = 0; i < 5; i++ ) {
- var dividerSegment = drawDividerSegment();
+ for ( let i = 0; i < 5; i++ ) {
+ const dividerSegment = drawDividerSegment();
dividerSegment.centerTop = new Vector2( getOffsetFromFrequency( frequency ), 2 * i * STRIP_HEIGHT / 9 );
thisNode.addChild( dividerSegment );
}
@@ -422,32 +422,32 @@ define( require => {
function ChirpNode() {
// Create and add the boundary and background.
- var boundingBoxHeight = SUBSECTION_WIDTH * 0.1; // Arbitrary, adjust as needed.
+ const boundingBoxHeight = SUBSECTION_WIDTH * 0.1; // Arbitrary, adjust as needed.
Rectangle.call( this, 0, 0, SUBSECTION_WIDTH, boundingBoxHeight, {
fill: 'rgb(237, 243, 246)',
lineWidth: 2,
stroke: 'black'
} );
- var chirpShape = new Shape();
+ const chirpShape = new Shape();
chirpShape.moveTo( 0, this.centerY ); // Move starting point to left center of bounding box.
- var numPointsOnLine = 1500;
- for ( var i = 0; i < numPointsOnLine; i++ ) {
- var x = i * (SUBSECTION_WIDTH / (numPointsOnLine - 1));
- var t = x / SUBSECTION_WIDTH;
+ const numPointsOnLine = 1500;
+ for ( let i = 0; i < numPointsOnLine; i++ ) {
+ const x = i * (SUBSECTION_WIDTH / (numPointsOnLine - 1));
+ const t = x / SUBSECTION_WIDTH;
- var f0 = 1;
- var k = 2;
- var tScale = 4.5;
- var sinTerm = Math.sin( 2 * Math.PI * f0 * (Math.pow( k, t * tScale ) - 1) / Math.log( k ) );
+ const f0 = 1;
+ const k = 2;
+ const tScale = 4.5;
+ const sinTerm = Math.sin( 2 * Math.PI * f0 * (Math.pow( k, t * tScale ) - 1) / Math.log( k ) );
- var y = (sinTerm * boundingBoxHeight * 0.40 + boundingBoxHeight / 2);
+ const y = (sinTerm * boundingBoxHeight * 0.40 + boundingBoxHeight / 2);
chirpShape.lineTo( x, y );
}
// Create the chirp node, but create it first with a null shape, then override computeShapeBounds, then set the
// shape. This makes the creation of this node far faster.
- var chirpNode = new Path( null, {
+ const chirpNode = new Path( null, {
lineWidth: 2,
stroke: 'black',
lineJoin: 'bevel'
diff --git a/js/moleculesandlight/view/WindowFrameNode.js b/js/moleculesandlight/view/WindowFrameNode.js
index 56fd553c..0c7f9d76 100644
--- a/js/moleculesandlight/view/WindowFrameNode.js
+++ b/js/moleculesandlight/view/WindowFrameNode.js
@@ -35,7 +35,7 @@ define( require => {
this.outerColor = outerColor; // @private
// Set the canvas bounds to the observation window dilated by the desired line width.
- var canvasBounds = observationWindow.bounds.dilated( this.lineWidth );
+ const canvasBounds = observationWindow.bounds.dilated( this.lineWidth );
CanvasNode.call( this, { canvasBounds: canvasBounds } );
this.invalidatePaint();
@@ -123,8 +123,8 @@ define( require => {
drawFrameCorner: function( corner, radialCenter, context ) {
// Determine the initial and final angles for arc methods based on input location.
- var initialAngle;
- var finalAngle;
+ let initialAngle;
+ let finalAngle;
switch( corner ) {
case 'topLeft':
initialAngle = Math.PI;
@@ -152,7 +152,7 @@ define( require => {
context.arc( radialCenter.x, radialCenter.y, this.observationWindow.cornerXRadius + this.lineWidth / 2, initialAngle, finalAngle, false );
// Create the radial gradient for the arc on the corner.
- var grad = context.createRadialGradient( radialCenter.x, radialCenter.y, this.observationWindow.cornerXRadius,
+ const grad = context.createRadialGradient( radialCenter.x, radialCenter.y, this.observationWindow.cornerXRadius,
radialCenter.x, radialCenter.y, this.lineWidth + this.observationWindow.cornerXRadius );
grad.addColorStop( 0, this.innerColor );
grad.addColorStop( 1, this.outerColor );
@@ -178,7 +178,7 @@ define( require => {
// Create the linear gradient and add some length or height buffers for the window frame pieces. Parameters of
// the gradient are dependent on the desired side of the frame.
- var grad;
+ let grad;
switch( side ) {
case 'top':
x--; // Extra length buffers for the width ensures continuity in the window frame.
diff --git a/js/photon-absorption/model/Molecule.js b/js/photon-absorption/model/Molecule.js
index 9d44ebf8..e0788bf2 100644
--- a/js/photon-absorption/model/Molecule.js
+++ b/js/photon-absorption/model/Molecule.js
@@ -25,16 +25,16 @@ define( require => {
const Vector2Property = require( 'DOT/Vector2Property' );
// constants
- var PHOTON_EMISSION_SPEED = 3000; // Picometers per second.
- var PHOTON_ABSORPTION_DISTANCE = 100; // Distance where the molecule begins to query photon for absorption.
- var VIBRATION_FREQUENCY = 5; // Cycles per second of sim time.
- var ROTATION_RATE = 1.1; // Revolutions per second of sim time.
- var ABSORPTION_HYSTERESIS_TIME = 0.2; // seconds
- var PASS_THROUGH_PHOTON_LIST_SIZE = 10; // Size of list which tracks photons not absorbed due to random probability.
+ const PHOTON_EMISSION_SPEED = 3000; // Picometers per second.
+ const PHOTON_ABSORPTION_DISTANCE = 100; // Distance where the molecule begins to query photon for absorption.
+ const VIBRATION_FREQUENCY = 5; // Cycles per second of sim time.
+ const ROTATION_RATE = 1.1; // Revolutions per second of sim time.
+ const ABSORPTION_HYSTERESIS_TIME = 0.2; // seconds
+ const PASS_THROUGH_PHOTON_LIST_SIZE = 10; // Size of list which tracks photons not absorbed due to random probability.
// utility method used for serialization
function serializeArray( array ) {
- var serializedArray = [];
+ const serializedArray = [];
array.forEach( function( arrayElement ) {
serializedArray.push( arrayElement.toStateObject() );
} );
@@ -43,7 +43,7 @@ define( require => {
// utility method for finding atom with the specified ID in a list
function findAtomWithID( atomArray, id ) {
- for ( var i = 0; i < atomArray.length; i++ ) {
+ for ( let i = 0; i < atomArray.length; i++ ) {
if ( atomArray[ i ].uniqueID === id ) {
return atomArray[ i ];
}
@@ -263,7 +263,7 @@ define( require => {
}
if ( this.rotatingProperty.get() ) {
- var directionMultiplier = this.rotationDirectionClockwiseProperty.get() ? -1 : 1;
+ const directionMultiplier = this.rotationDirectionClockwiseProperty.get() ? -1 : 1;
this.rotate( dt * ROTATION_RATE * 2 * Math.PI * directionMultiplier );
}
@@ -406,7 +406,7 @@ define( require => {
**/
queryAbsorbPhoton: function( photon ) {
- var absorbPhoton = false;
+ let absorbPhoton = false;
if ( !this.isPhotonAbsorbed() &&
this.absorptionHysteresisCountdownTime <= 0 &&
@@ -414,7 +414,7 @@ define( require => {
// The circumstances for absorption are correct, but do we have an absorption strategy for this photon's
// wavelength?
- var candidateAbsorptionStrategy = this.mapWavelengthToAbsorptionStrategy[ photon.wavelength ];
+ const candidateAbsorptionStrategy = this.mapWavelengthToAbsorptionStrategy[ photon.wavelength ];
if ( typeof candidateAbsorptionStrategy !== 'undefined' ) {
// Yes, there is a strategy available for this wavelength.
// Ask it if it wants the photon.
@@ -462,11 +462,11 @@ define( require => {
* @param {number} wavelength - The photon to be emitted.
**/
emitPhoton: function( wavelength ) {
- var photonToEmit = new Photon( wavelength, this.photonGroupTandem.createNextTandem() );
- var emissionAngle = phet.joist.random.nextDouble() * Math.PI * 2;
+ const photonToEmit = new Photon( wavelength, this.photonGroupTandem.createNextTandem() );
+ const emissionAngle = phet.joist.random.nextDouble() * Math.PI * 2;
photonToEmit.setVelocity( PHOTON_EMISSION_SPEED * Math.cos( emissionAngle ),
( PHOTON_EMISSION_SPEED * Math.sin( emissionAngle ) ) );
- var centerOfGravityPosRef = this.centerOfGravityProperty.get();
+ const centerOfGravityPosRef = this.centerOfGravityProperty.get();
photonToEmit.location = new Vector2( centerOfGravityPosRef.x, centerOfGravityPosRef.y );
this.absorptionHysteresisCountdownTime = ABSORPTION_HYSTERESIS_TIME;
this.photonEmittedEmitter.emit( photonToEmit );
@@ -479,9 +479,9 @@ define( require => {
**/
updateAtomPositions: function() {
- for ( var uniqueID in this.initialAtomCogOffsets ) {
+ for ( const uniqueID in this.initialAtomCogOffsets ) {
if ( this.initialAtomCogOffsets.hasOwnProperty( uniqueID ) ) {
- var atomOffset = new Vector2( this.initialAtomCogOffsets[ uniqueID ].x, this.initialAtomCogOffsets[ uniqueID ].y );
+ const atomOffset = new Vector2( this.initialAtomCogOffsets[ uniqueID ].x, this.initialAtomCogOffsets[ uniqueID ].y );
// Add the vibration, if any exists.
atomOffset.add( this.vibrationAtomOffsets[ uniqueID ] );
// Rotate.
@@ -522,7 +522,7 @@ define( require => {
fromStateObject: function( stateObject ) {
// Create a molecule that is basically blank.
- var molecule = new Molecule();
+ const molecule = new Molecule();
// Fill in the straightforward stuff
molecule.highElectronicEnergyStateProperty.set( stateObject.highElectronicEnergyState );
@@ -537,8 +537,8 @@ define( require => {
// add the bonds
stateObject.atomicBonds.forEach( function( bondStateObject ) {
- var atom1 = findAtomWithID( molecule.atoms, bondStateObject.atom1ID );
- var atom2 = findAtomWithID( molecule.atoms, bondStateObject.atom2ID );
+ const atom1 = findAtomWithID( molecule.atoms, bondStateObject.atom1ID );
+ const atom2 = findAtomWithID( molecule.atoms, bondStateObject.atom2ID );
assert && assert( atom1 && atom2, 'Error: Couldn\'t match atom ID in bond with atoms in molecule' );
molecule.addAtomicBond( new AtomicBond( atom1, atom2, { bondCount: bondStateObject.bondCount } ) );
} );
diff --git a/js/photon-absorption/model/PhotonAbsorptionModel.js b/js/photon-absorption/model/PhotonAbsorptionModel.js
index e708beb4..5561d93d 100644
--- a/js/photon-absorption/model/PhotonAbsorptionModel.js
+++ b/js/photon-absorption/model/PhotonAbsorptionModel.js
@@ -49,20 +49,20 @@ define( require => {
// ------- constants -------------
// constants that control where and how photons are emitted.
- var PHOTON_EMISSION_LOCATION = new Vector2( -2000, 0 );
+ const PHOTON_EMISSION_LOCATION = new Vector2( -2000, 0 );
// Velocity of emitted photons. Since they are emitted horizontally, only one value is needed.
- var PHOTON_VELOCITY = 3000; // picometers/second
+ const PHOTON_VELOCITY = 3000; // picometers/second
// Defaults for photon emission periods.
- var DEFAULT_PHOTON_EMISSION_PERIOD = Number.POSITIVE_INFINITY; // Milliseconds of sim time.
+ const DEFAULT_PHOTON_EMISSION_PERIOD = Number.POSITIVE_INFINITY; // Milliseconds of sim time.
// Default values for various parameters that weren't already covered.
- var DEFAULT_EMITTED_PHOTON_WAVELENGTH = WavelengthConstants.IR_WAVELENGTH;
- var INITIAL_COUNTDOWN_WHEN_EMISSION_ENABLED = 0.3; // seconds
+ const DEFAULT_EMITTED_PHOTON_WAVELENGTH = WavelengthConstants.IR_WAVELENGTH;
+ const INITIAL_COUNTDOWN_WHEN_EMISSION_ENABLED = 0.3; // seconds
// Minimum for photon emission periods.
- var MIN_PHOTON_EMISSION_PERIOD_SINGLE_TARGET = 0.4; // seconds
+ const MIN_PHOTON_EMISSION_PERIOD_SINGLE_TARGET = 0.4; // seconds
/**
* Constructor for a photon absorption model.
@@ -73,7 +73,7 @@ define( require => {
*/
function PhotonAbsorptionModel( initialPhotonTarget, tandem ) {
- var self = this;
+ const self = this;
this.photonAbsorptionModel = tandem; // @private
@@ -132,7 +132,7 @@ define( require => {
self.setPhotonEmissionPeriod( Number.POSITIVE_INFINITY );
}
else {
- var singleTargetPeriodFrequency = self.getSingleTargetPeriodFromFrequency( emissionFrequency );
+ const singleTargetPeriodFrequency = self.getSingleTargetPeriodFromFrequency( emissionFrequency );
self.setPhotonEmissionPeriod( singleTargetPeriodFrequency );
}
} );
@@ -161,7 +161,7 @@ define( require => {
this.photons.clear();
// Reset all active molecules, which will stop any vibrations.
- for ( var molecule = 0; molecule < this.activeMolecules.length; molecule++ ) {
+ for ( let molecule = 0; molecule < this.activeMolecules.length; molecule++ ) {
this.activeMolecules.get( molecule ).reset();
}
@@ -227,8 +227,8 @@ define( require => {
* @param {number} dt - the incremental times step, in seconds
*/
stepPhotons: function( dt ) {
- var self = this;
- var photonsToRemove = [];
+ const self = this;
+ const photonsToRemove = [];
// check for possible interaction between each photon and molecule
this.photons.forEach( function( photon ) {
@@ -243,13 +243,13 @@ define( require => {
// Remove any photons that were marked for removal.
this.photons.removeAll( photonsToRemove );
- for ( var i = 0; i < photonsToRemove.length; i++ ) {
+ for ( let i = 0; i < photonsToRemove.length; i++ ) {
photonsToRemove[ i ].dispose();
}
},
clearPhotons: function() {
- for ( var i = 0; i < this.photons.length; i++ ) {
+ for ( let i = 0; i < this.photons.length; i++ ) {
this.photons.get( i ).dispose();
}
this.photons.clear();
@@ -261,8 +261,8 @@ define( require => {
* @param {number} dt - The incremental time step.
*/
stepMolecules: function( dt ) {
- var moleculesToStep = this.activeMolecules.getArray().slice( 0 );
- for ( var molecule = 0; molecule < moleculesToStep.length; molecule++ ) {
+ const moleculesToStep = this.activeMolecules.getArray().slice( 0 );
+ for ( let molecule = 0; molecule < moleculesToStep.length; molecule++ ) {
moleculesToStep[ molecule ].step( dt );
}
},
@@ -290,9 +290,9 @@ define( require => {
* frames.
*/
emitPhoton: function( advanceAmount ) {
- var photon = new Photon( this.photonWavelengthProperty.get(), this.photonGroupTandem.createNextTandem() );
+ const photon = new Photon( this.photonWavelengthProperty.get(), this.photonGroupTandem.createNextTandem() );
photon.locationProperty.set( new Vector2( PHOTON_EMISSION_LOCATION.x + PHOTON_VELOCITY * advanceAmount, PHOTON_EMISSION_LOCATION.y ) );
- var emissionAngle = 0; // Straight to the right.
+ const emissionAngle = 0; // Straight to the right.
photon.setVelocity( PHOTON_VELOCITY * Math.cos( emissionAngle ), PHOTON_VELOCITY * Math.sin( emissionAngle ) );
this.photons.add( photon );
},
@@ -374,7 +374,7 @@ define( require => {
*/
updateActiveMolecule: function( photonTarget, tandem ) {
- var self = this;
+ const self = this;
this.activeMolecules.forEach( function( molecule ) { molecule.dispose(); } );
@@ -382,7 +382,7 @@ define( require => {
this.activeMolecules.clear(); // Clear the old active molecules array
// Add the new photon target(s).
- var newMolecule =
+ const newMolecule =
photonTarget === PhotonTarget.SINGLE_CO_MOLECULE ? new CO( { tandem: tandem.createTandem( 'CO' ) } ) :
photonTarget === PhotonTarget.SINGLE_CO2_MOLECULE ? new CO2( { tandem: tandem.createTandem( 'CO2' ) } ) :
photonTarget === PhotonTarget.SINGLE_H2O_MOLECULE ? new H2O( { tandem: tandem.createTandem( 'H2O' ) } ) :
@@ -430,7 +430,7 @@ define( require => {
* in cases where an atom has broken apart and needs to be restored to its original condition.
*/
restoreActiveMolecule: function() {
- var currentTarget = this.photonTargetProperty.get();
+ const currentTarget = this.photonTargetProperty.get();
this.updateActiveMolecule( currentTarget, this.photonAbsorptionModel );
}
} );
diff --git a/js/photon-absorption/model/PhotonAbsorptionModelIO.js b/js/photon-absorption/model/PhotonAbsorptionModelIO.js
index f43c2cda..e53e8aef 100644
--- a/js/photon-absorption/model/PhotonAbsorptionModelIO.js
+++ b/js/photon-absorption/model/PhotonAbsorptionModelIO.js
@@ -31,9 +31,9 @@ define( require => {
*/
static addChildInstance( photonAbsorptionModel, tandem, stateObject ) {
validate( photonAbsorptionModel, this.validator );
- var value = PhotonIO.fromStateObject( stateObject );
+ const value = PhotonIO.fromStateObject( stateObject );
- var photon = new phet.moleculesAndLight.Photon( value.wavelength, tandem );
+ const photon = new phet.moleculesAndLight.Photon( value.wavelength, tandem );
photon.setVelocity( stateObject.vx, stateObject.vy );
photonAbsorptionModel.photons.add( photon );
}
diff --git a/js/photon-absorption/model/PhotonAbsorptionStrategy.js b/js/photon-absorption/model/PhotonAbsorptionStrategy.js
index 6f4c195a..855d388e 100644
--- a/js/photon-absorption/model/PhotonAbsorptionStrategy.js
+++ b/js/photon-absorption/model/PhotonAbsorptionStrategy.js
@@ -21,8 +21,8 @@ define( require => {
const moleculesAndLight = require( 'MOLECULES_AND_LIGHT/moleculesAndLight' );
const Property = require( 'AXON/Property' );
- var MIN_PHOTON_HOLD_TIME = 0.6; // seconds of sim time
- var MAX_PHOTON_HOLD_TIME = 1.2; // seconds of sim time
+ const MIN_PHOTON_HOLD_TIME = 0.6; // seconds of sim time
+ const MAX_PHOTON_HOLD_TIME = 1.2; // seconds of sim time
/**
* Constructor for photon absorption strategy.
@@ -65,7 +65,7 @@ define( require => {
queryAndAbsorbPhoton: function( photon ) {
// All circumstances are correct for photon absorption, so now we decide probabilistically whether or not to
// actually do it. This essentially simulates the quantum nature of the absorption.
- var absorbed = (!this.isPhotonAbsorbed) && ( phet.joist.random.nextDouble() < this.photonAbsorptionProbabilityProperty.get() );
+ const absorbed = (!this.isPhotonAbsorbed) && ( phet.joist.random.nextDouble() < this.photonAbsorptionProbabilityProperty.get() );
if ( absorbed ) {
this.isPhotonAbsorbed = true;
this.photonHoldCountdownTime = MIN_PHOTON_HOLD_TIME + phet.joist.random.nextDouble() * ( MAX_PHOTON_HOLD_TIME - MIN_PHOTON_HOLD_TIME );
diff --git a/js/photon-absorption/model/PhotonHoldStrategy.js b/js/photon-absorption/model/PhotonHoldStrategy.js
index aff785f3..8f63f6d8 100644
--- a/js/photon-absorption/model/PhotonHoldStrategy.js
+++ b/js/photon-absorption/model/PhotonHoldStrategy.js
@@ -67,7 +67,7 @@ define( require => {
**/
queryAndAbsorbPhoton: function( photon ) {
- var absorbed = PhotonAbsorptionStrategy.prototype.queryAndAbsorbPhoton.call( this, photon );
+ const absorbed = PhotonAbsorptionStrategy.prototype.queryAndAbsorbPhoton.call( this, photon );
if ( absorbed ) {
this.absorbedWavelength = photon.wavelength;
this.photonAbsorbed();
diff --git a/js/photon-absorption/model/RotationStrategy.js b/js/photon-absorption/model/RotationStrategy.js
index b250a1d0..7dd2fa0b 100644
--- a/js/photon-absorption/model/RotationStrategy.js
+++ b/js/photon-absorption/model/RotationStrategy.js
@@ -14,7 +14,7 @@ define( require => {
const PhotonHoldStrategy = require( 'MOLECULES_AND_LIGHT/photon-absorption/model/PhotonHoldStrategy' );
//Random boolean generator.
- var RAND = {
+ const RAND = {
nextBoolean: function() {
return phet.joist.random.nextDouble() < 0.50;
}
diff --git a/js/photon-absorption/model/WavelengthConstants.js b/js/photon-absorption/model/WavelengthConstants.js
index dc1a66ed..e5c27e48 100644
--- a/js/photon-absorption/model/WavelengthConstants.js
+++ b/js/photon-absorption/model/WavelengthConstants.js
@@ -18,7 +18,7 @@ define( require => {
const quadWavelengthSelectorUltravioletString = require( 'string!MOLECULES_AND_LIGHT/QuadWavelengthSelector.Ultraviolet' );
const quadWavelengthSelectorVisibleString = require( 'string!MOLECULES_AND_LIGHT/QuadWavelengthSelector.Visible' );
- var WavelengthConstants = {
+ const WavelengthConstants = {
// all values in meters
SUNLIGHT_WAVELENGTH: 400E-9, // Ported from the original JAVA version, but not used in Molecules And Light
diff --git a/js/photon-absorption/model/atoms/Atom.js b/js/photon-absorption/model/atoms/Atom.js
index c1e032cb..53448b6e 100644
--- a/js/photon-absorption/model/atoms/Atom.js
+++ b/js/photon-absorption/model/atoms/Atom.js
@@ -18,7 +18,7 @@ define( require => {
const PhetColorScheme = require( 'SCENERY_PHET/PhetColorScheme' );
// Static data
- var instanceCount = 0; // Base count for the unique ID of this atom.
+ let instanceCount = 0; // Base count for the unique ID of this atom.
/**
* Constructor for creating an individual atom. This is generally invoked using factory methods for specify atoms.
diff --git a/js/photon-absorption/model/molecules/CH4.js b/js/photon-absorption/model/molecules/CH4.js
index 4fb167cd..853a4e22 100644
--- a/js/photon-absorption/model/molecules/CH4.js
+++ b/js/photon-absorption/model/molecules/CH4.js
@@ -21,15 +21,15 @@ define( require => {
const WavelengthConstants = require( 'MOLECULES_AND_LIGHT/photon-absorption/model/WavelengthConstants' );
// Model Data for Methane
- var INITIAL_CARBON_HYDROGEN_DISTANCE = 170; // In picometers.
+ const INITIAL_CARBON_HYDROGEN_DISTANCE = 170; // In picometers.
// Assume that the angle from the carbon to the hydrogen is 45 degrees.
- var ROTATED_INITIAL_CARBON_HYDROGEN_DISTANCE = INITIAL_CARBON_HYDROGEN_DISTANCE * Math.sin( Math.PI / 4 );
+ const ROTATED_INITIAL_CARBON_HYDROGEN_DISTANCE = INITIAL_CARBON_HYDROGEN_DISTANCE * Math.sin( Math.PI / 4 );
- var HYDROGEN_VIBRATION_DISTANCE = 30;
- var HYDROGEN_VIBRATION_ANGLE = Math.PI / 4;
- var HYDROGEN_VIBRATION_DISTANCE_X = HYDROGEN_VIBRATION_DISTANCE * Math.cos( HYDROGEN_VIBRATION_ANGLE );
- var HYDROGEN_VIBRATION_DISTANCE_Y = HYDROGEN_VIBRATION_DISTANCE * Math.sin( HYDROGEN_VIBRATION_ANGLE );
+ const HYDROGEN_VIBRATION_DISTANCE = 30;
+ const HYDROGEN_VIBRATION_ANGLE = Math.PI / 4;
+ const HYDROGEN_VIBRATION_DISTANCE_X = HYDROGEN_VIBRATION_DISTANCE * Math.cos( HYDROGEN_VIBRATION_ANGLE );
+ const HYDROGEN_VIBRATION_DISTANCE_Y = HYDROGEN_VIBRATION_DISTANCE * Math.sin( HYDROGEN_VIBRATION_ANGLE );
/**
* Constructor for a Methane molecule.
@@ -102,7 +102,7 @@ define( require => {
// Molecule.prototype.setVibration.call( this, vibrationRadians );
this.currentVibrationRadians = vibrationRadians;
- var multFactor = Math.sin( vibrationRadians );
+ const multFactor = Math.sin( vibrationRadians );
if ( vibrationRadians !== 0 ) {
this.addInitialAtomCogOffset( this.hydrogenAtom1, new Vector2( -ROTATED_INITIAL_CARBON_HYDROGEN_DISTANCE + multFactor * HYDROGEN_VIBRATION_DISTANCE_X,
@@ -115,10 +115,10 @@ define( require => {
-ROTATED_INITIAL_CARBON_HYDROGEN_DISTANCE + multFactor * HYDROGEN_VIBRATION_DISTANCE_Y ) );
// Position the carbon atom so that the center of mass of the molecule remains the same.
- var carbonXPos = -( this.hydrogenAtom1.mass / this.carbonAtom.mass ) *
+ const carbonXPos = -( this.hydrogenAtom1.mass / this.carbonAtom.mass ) *
( this.getInitialAtomCogOffset( this.hydrogenAtom1 ).x + this.getInitialAtomCogOffset( this.hydrogenAtom2 ).x +
this.getInitialAtomCogOffset( this.hydrogenAtom3 ).x + this.getInitialAtomCogOffset( this.hydrogenAtom4 ).x );
- var carbonYPos = -( this.hydrogenAtom1.mass / this.carbonAtom.mass ) *
+ const carbonYPos = -( this.hydrogenAtom1.mass / this.carbonAtom.mass ) *
( this.getInitialAtomCogOffset( this.hydrogenAtom1 ).y + this.getInitialAtomCogOffset( this.hydrogenAtom2 ).y +
this.getInitialAtomCogOffset( this.hydrogenAtom3 ).y + this.getInitialAtomCogOffset( this.hydrogenAtom4 ).y );
this.addInitialAtomCogOffset( this.carbonAtom, new Vector2( carbonXPos, carbonYPos ) );
diff --git a/js/photon-absorption/model/molecules/CO.js b/js/photon-absorption/model/molecules/CO.js
index cd9c4bf1..70ec5462 100644
--- a/js/photon-absorption/model/molecules/CO.js
+++ b/js/photon-absorption/model/molecules/CO.js
@@ -22,8 +22,8 @@ define( require => {
const WavelengthConstants = require( 'MOLECULES_AND_LIGHT/photon-absorption/model/WavelengthConstants' );
// Model Data for the carbon monoxide molecule
- var INITIAL_CARBON_OXYGEN_DISTANCE = 170; // In picometers.
- var VIBRATION_MAGNITUDE = 20; // In picometers.
+ const INITIAL_CARBON_OXYGEN_DISTANCE = 170; // In picometers.
+ const VIBRATION_MAGNITUDE = 20; // In picometers.
/**
* Constructor for a carbon monoxide molecule.
@@ -67,7 +67,7 @@ define( require => {
setVibration: function( vibrationRadians ) {
this.currentVibrationRadians = vibrationRadians;
- var multFactor = Math.sin( vibrationRadians );
+ const multFactor = Math.sin( vibrationRadians );
this.getVibrationAtomOffset( this.carbonAtom ).setXY( VIBRATION_MAGNITUDE * multFactor, 0 );
this.getVibrationAtomOffset( this.oxygenAtom ).setXY( -VIBRATION_MAGNITUDE * multFactor, 0 );
this.updateAtomPositions();
diff --git a/js/photon-absorption/model/molecules/CO2.js b/js/photon-absorption/model/molecules/CO2.js
index c1b98cfd..6e225b9d 100644
--- a/js/photon-absorption/model/molecules/CO2.js
+++ b/js/photon-absorption/model/molecules/CO2.js
@@ -20,13 +20,13 @@ define( require => {
const WavelengthConstants = require( 'MOLECULES_AND_LIGHT/photon-absorption/model/WavelengthConstants' );
// Model Data for the carbon dioxide molecule.
- var INITIAL_CARBON_OXYGEN_DISTANCE = 170; // In picometers.
+ const INITIAL_CARBON_OXYGEN_DISTANCE = 170; // In picometers.
// Deflection amounts used for the vibration of the CO2 atoms. These
// are calculated such that the actual center of gravity should remain
// constant.
- var CARBON_MAX_DEFLECTION = 40;
- var OXYGEN_MAX_DEFLECTION = Atom.carbon().mass * CARBON_MAX_DEFLECTION / ( 2 * Atom.oxygen().mass );
+ const CARBON_MAX_DEFLECTION = 40;
+ const OXYGEN_MAX_DEFLECTION = Atom.carbon().mass * CARBON_MAX_DEFLECTION / ( 2 * Atom.oxygen().mass );
/**
* Constructor for a carbon dioxide molecule.
@@ -73,7 +73,7 @@ define( require => {
setVibration: function( vibrationRadians ) {
this.currentVibrationRadians = vibrationRadians;
- var multFactor = Math.sin( vibrationRadians );
+ const multFactor = Math.sin( vibrationRadians );
this.addInitialAtomCogOffset( this.carbonAtom, new Vector2( 0, multFactor * CARBON_MAX_DEFLECTION ) );
this.addInitialAtomCogOffset( this.oxygenAtom1, new Vector2( INITIAL_CARBON_OXYGEN_DISTANCE, -multFactor * OXYGEN_MAX_DEFLECTION ) );
this.addInitialAtomCogOffset( this.oxygenAtom2, new Vector2( -INITIAL_CARBON_OXYGEN_DISTANCE, -multFactor * OXYGEN_MAX_DEFLECTION ) );
diff --git a/js/photon-absorption/model/molecules/H2O.js b/js/photon-absorption/model/molecules/H2O.js
index 7321c434..b803413f 100644
--- a/js/photon-absorption/model/molecules/H2O.js
+++ b/js/photon-absorption/model/molecules/H2O.js
@@ -25,10 +25,10 @@ define( require => {
// These constants define the initial shape of the water atom. The angle between the atoms is intended to be correct,
// and the bond is somewhat longer than real life. The algebraic calculations are intended to make it so that the
// bond length and/or the angle could be changed and the correct center of gravity will be maintained.
- var OXYGEN_HYDROGEN_BOND_LENGTH = 130;
- var INITIAL_HYDROGEN_OXYGEN_HYDROGEN_ANGLE = 109 * Math.PI / 180;
- var INITIAL_MOLECULE_HEIGHT = OXYGEN_HYDROGEN_BOND_LENGTH * Math.cos( INITIAL_HYDROGEN_OXYGEN_HYDROGEN_ANGLE / 2 );
- var INITIAL_HYDROGEN_HORIZONTAL_OFFSET = OXYGEN_HYDROGEN_BOND_LENGTH * Math.sin( INITIAL_HYDROGEN_OXYGEN_HYDROGEN_ANGLE / 2 );
+ const OXYGEN_HYDROGEN_BOND_LENGTH = 130;
+ const INITIAL_HYDROGEN_OXYGEN_HYDROGEN_ANGLE = 109 * Math.PI / 180;
+ const INITIAL_MOLECULE_HEIGHT = OXYGEN_HYDROGEN_BOND_LENGTH * Math.cos( INITIAL_HYDROGEN_OXYGEN_HYDROGEN_ANGLE / 2 );
+ const INITIAL_HYDROGEN_HORIZONTAL_OFFSET = OXYGEN_HYDROGEN_BOND_LENGTH * Math.sin( INITIAL_HYDROGEN_OXYGEN_HYDROGEN_ANGLE / 2 );
/**
* Constructor for a water molecule.
@@ -91,9 +91,9 @@ define( require => {
setVibration: function( vibrationRadians ) {
this.currentVibrationRadians = vibrationRadians;
- var multFactor = Math.sin( vibrationRadians );
- var maxOxygenDisplacement = 3;
- var maxHydrogenDisplacement = 18;
+ const multFactor = Math.sin( vibrationRadians );
+ const maxOxygenDisplacement = 3;
+ const maxHydrogenDisplacement = 18;
this.addInitialAtomCogOffset( this.oxygenAtom, new Vector2( 0, this.initialOxygenVerticalOffset - multFactor * maxOxygenDisplacement ) );
this.addInitialAtomCogOffset( this.hydrogenAtom1, new Vector2( INITIAL_HYDROGEN_HORIZONTAL_OFFSET + multFactor * maxHydrogenDisplacement,
this.initialHydrogenVerticalOffset + multFactor * maxHydrogenDisplacement ) );
diff --git a/js/photon-absorption/model/molecules/N2.js b/js/photon-absorption/model/molecules/N2.js
index 5655f2ff..95d5e21c 100644
--- a/js/photon-absorption/model/molecules/N2.js
+++ b/js/photon-absorption/model/molecules/N2.js
@@ -19,7 +19,7 @@ define( require => {
const Vector2 = require( 'DOT/Vector2' );
// Model data for nitrogen molecule
- var INITIAL_NITROGEN_NITROGEN_DISTANCE = 170; // In picometers.
+ const INITIAL_NITROGEN_NITROGEN_DISTANCE = 170; // In picometers.
/**
* Constructor for a molecule of nitrogen.
diff --git a/js/photon-absorption/model/molecules/NO.js b/js/photon-absorption/model/molecules/NO.js
index 844db8a6..21894479 100644
--- a/js/photon-absorption/model/molecules/NO.js
+++ b/js/photon-absorption/model/molecules/NO.js
@@ -19,7 +19,7 @@ define( require => {
const Vector2 = require( 'DOT/Vector2' );
// Model Data for the nitrogen monoxide molecule.
- var INITIAL_NITROGEN_OXYGEN_DISTANCE = 170; // In picometers.
+ const INITIAL_NITROGEN_OXYGEN_DISTANCE = 170; // In picometers.
/**
* Constructor for a nitrogen monoxide molecule.
diff --git a/js/photon-absorption/model/molecules/NO2.js b/js/photon-absorption/model/molecules/NO2.js
index 75fdeba4..ed939f8a 100644
--- a/js/photon-absorption/model/molecules/NO2.js
+++ b/js/photon-absorption/model/molecules/NO2.js
@@ -28,13 +28,13 @@ define( require => {
// These constants define the initial shape of the NO2 atom. The angle between the atoms is intended to be correct,
// and the bond is somewhat longer than real life. The algebraic calculations are intended to make it so that the
// bond length and/or the angle could be changed and the correct center of gravity will be maintained.
- var NITROGEN_OXYGEN_BOND_LENGTH = 180;
- var INITIAL_OXYGEN_NITROGEN_OXYGEN_ANGLE = 120 * Math.PI / 180; // In radians.
- var INITIAL_MOLECULE_HEIGHT = NITROGEN_OXYGEN_BOND_LENGTH * Math.cos( INITIAL_OXYGEN_NITROGEN_OXYGEN_ANGLE / 2 );
- var BREAK_APART_VELOCITY = 3000;
+ const NITROGEN_OXYGEN_BOND_LENGTH = 180;
+ const INITIAL_OXYGEN_NITROGEN_OXYGEN_ANGLE = 120 * Math.PI / 180; // In radians.
+ const INITIAL_MOLECULE_HEIGHT = NITROGEN_OXYGEN_BOND_LENGTH * Math.cos( INITIAL_OXYGEN_NITROGEN_OXYGEN_ANGLE / 2 );
+ const BREAK_APART_VELOCITY = 3000;
//Random boolean generator. Used to control the side on which the delocalized bond is depicted.
- var RAND = {
+ const RAND = {
nextBoolean: function() {
return phet.joist.random.nextDouble() < 0.50;
}
@@ -120,9 +120,9 @@ define( require => {
setVibration: function( vibrationRadians ) {
this.currentVibrationRadians = vibrationRadians;
- var multFactor = Math.sin( vibrationRadians );
- var maxNitrogenDisplacement = 30;
- var maxOxygenDisplacement = 15;
+ const multFactor = Math.sin( vibrationRadians );
+ const maxNitrogenDisplacement = 30;
+ const maxOxygenDisplacement = 15;
this.addInitialAtomCogOffset( this.nitrogenAtom, new Vector2( 0, this.initialNitrogenVerticalOffset - multFactor * maxNitrogenDisplacement ) );
this.addInitialAtomCogOffset( this.rightOxygenAtom, new Vector2( this.initialOxygenHorizontalOffset + multFactor * maxOxygenDisplacement,
this.initialOxygenVerticalOffset + multFactor * maxOxygenDisplacement ) );
@@ -139,8 +139,8 @@ define( require => {
breakApart: function() {
// Create the constituent molecules that result from breaking apart and add them to the activeMolecules observable array.
- var nitrogenMonoxideMolecule = new NO();
- var singleOxygenMolecule = new O();
+ const nitrogenMonoxideMolecule = new NO();
+ const singleOxygenMolecule = new O();
this.brokeApartEmitter.emit( nitrogenMonoxideMolecule, singleOxygenMolecule );
// Set up the direction and velocity of the constituent molecules. These are set up mostly to look good, and their
@@ -148,8 +148,8 @@ define( require => {
// the molecule happens to have been rotated before breaking apart, it is rotated back to the initial orientation
// before dissociation. This keeps things simple, and makes the products go off the top and bottom of the window
// instead of potentially going back towards the photon source. See issue #110.
- var diatomicMoleculeRotationAngle = ( ( Math.PI / 2 ) - ( INITIAL_OXYGEN_NITROGEN_OXYGEN_ANGLE / 2 ) );
- var breakApartAngle;
+ const diatomicMoleculeRotationAngle = ( ( Math.PI / 2 ) - ( INITIAL_OXYGEN_NITROGEN_OXYGEN_ANGLE / 2 ) );
+ let breakApartAngle;
if ( this.doubleBondOnRight ) {
nitrogenMonoxideMolecule.rotate( -diatomicMoleculeRotationAngle );
nitrogenMonoxideMolecule.setCenterOfGravityPos( ( this.getInitialAtomCogOffset( this.nitrogenAtom ).x + this.getInitialAtomCogOffset( this.rightOxygenAtom ).x ) / 2,
diff --git a/js/photon-absorption/model/molecules/O2.js b/js/photon-absorption/model/molecules/O2.js
index dfe47412..05fc3484 100644
--- a/js/photon-absorption/model/molecules/O2.js
+++ b/js/photon-absorption/model/molecules/O2.js
@@ -18,7 +18,7 @@ define( require => {
const Vector2 = require( 'DOT/Vector2' );
// Model data for nitrogen molecule
- var INITIAL_OXYGEN_OXYGEN_DISTANCE = 170; // In picometers.
+ const INITIAL_OXYGEN_OXYGEN_DISTANCE = 170; // In picometers.
/**
* Constructor for an oxygen molecule
diff --git a/js/photon-absorption/model/molecules/O3.js b/js/photon-absorption/model/molecules/O3.js
index b2d8e571..760930df 100644
--- a/js/photon-absorption/model/molecules/O3.js
+++ b/js/photon-absorption/model/molecules/O3.js
@@ -27,17 +27,17 @@ define( require => {
// These constants define the initial shape of the O3 atom. The angle between the atoms is intended to be correct,
// and the bond is somewhat longer than real life. The algebraic calculations are intended to make it so that the
// bond length and/or the angle could be changed and the correct center of gravity will be maintained.
- var OXYGEN_OXYGEN_BOND_LENGTH = 180;
- var INITIAL_OXYGEN_OXYGEN_OXYGEN_ANGLE = 120 * Math.PI / 180; // In radians.
- var INITIAL_MOLECULE_HEIGHT = OXYGEN_OXYGEN_BOND_LENGTH * Math.cos( INITIAL_OXYGEN_OXYGEN_OXYGEN_ANGLE / 2 );
- var INITIAL_MOLECULE_WIDTH = 2 * OXYGEN_OXYGEN_BOND_LENGTH * Math.sin( INITIAL_OXYGEN_OXYGEN_OXYGEN_ANGLE / 2 );
- var INITIAL_CENTER_OXYGEN_VERTICAL_OFFSET = 2.0 / 3.0 * INITIAL_MOLECULE_HEIGHT;
- var INITIAL_OXYGEN_VERTICAL_OFFSET = -INITIAL_CENTER_OXYGEN_VERTICAL_OFFSET / 2;
- var INITIAL_OXYGEN_HORIZONTAL_OFFSET = INITIAL_MOLECULE_WIDTH / 2;
- var BREAK_APART_VELOCITY = 3000;
+ const OXYGEN_OXYGEN_BOND_LENGTH = 180;
+ const INITIAL_OXYGEN_OXYGEN_OXYGEN_ANGLE = 120 * Math.PI / 180; // In radians.
+ const INITIAL_MOLECULE_HEIGHT = OXYGEN_OXYGEN_BOND_LENGTH * Math.cos( INITIAL_OXYGEN_OXYGEN_OXYGEN_ANGLE / 2 );
+ const INITIAL_MOLECULE_WIDTH = 2 * OXYGEN_OXYGEN_BOND_LENGTH * Math.sin( INITIAL_OXYGEN_OXYGEN_OXYGEN_ANGLE / 2 );
+ const INITIAL_CENTER_OXYGEN_VERTICAL_OFFSET = 2.0 / 3.0 * INITIAL_MOLECULE_HEIGHT;
+ const INITIAL_OXYGEN_VERTICAL_OFFSET = -INITIAL_CENTER_OXYGEN_VERTICAL_OFFSET / 2;
+ const INITIAL_OXYGEN_HORIZONTAL_OFFSET = INITIAL_MOLECULE_WIDTH / 2;
+ const BREAK_APART_VELOCITY = 3000;
//Random boolean generator. Used to control the side on which the delocalized bond is depicted.
- var RAND = {
+ const RAND = {
nextBoolean: function() {
return phet.joist.random.nextDouble() < 0.50;
}
@@ -116,9 +116,9 @@ define( require => {
setVibration: function( vibrationRadians ) {
this.currentVibrationRadians = vibrationRadians;
- var multFactor = Math.sin( vibrationRadians );
- var maxCenterOxygenDisplacement = 30;
- var maxOuterOxygenDisplacement = 15;
+ const multFactor = Math.sin( vibrationRadians );
+ const maxCenterOxygenDisplacement = 30;
+ const maxOuterOxygenDisplacement = 15;
this.getVibrationAtomOffset( this.centerOxygenAtom ).setXY( 0, multFactor * maxCenterOxygenDisplacement );
this.getVibrationAtomOffset( this.rightOxygenAtom ).setXY( -multFactor * maxOuterOxygenDisplacement, -multFactor * maxOuterOxygenDisplacement );
this.getVibrationAtomOffset( this.leftOxygenAtom ).setXY( multFactor * maxOuterOxygenDisplacement, -multFactor * maxOuterOxygenDisplacement );
@@ -132,8 +132,8 @@ define( require => {
breakApart: function() {
// Create the constituent molecules that result from breaking apart.
- var diatomicOxygenMolecule = new O2();
- var singleOxygenMolecule = new O();
+ const diatomicOxygenMolecule = new O2();
+ const singleOxygenMolecule = new O();
this.brokeApartEmitter.emit( diatomicOxygenMolecule, singleOxygenMolecule );
// Set up the direction and velocity of the constituent molecules. These are set up mostly to look good, and their
@@ -141,8 +141,8 @@ define( require => {
// the molecule happens to have been rotated before breaking apart, it is rotated back to the initial orientation
// before dissociation. This keeps things simple, and makes the products go off the top and bottom of the window
// instead of potentially going back towards the photon source. See issue #110.
- var diatomicMoleculeRotationAngle = ( ( Math.PI / 2 ) - ( INITIAL_OXYGEN_OXYGEN_OXYGEN_ANGLE / 2 ) );
- var breakApartAngle;
+ const diatomicMoleculeRotationAngle = ( ( Math.PI / 2 ) - ( INITIAL_OXYGEN_OXYGEN_OXYGEN_ANGLE / 2 ) );
+ let breakApartAngle;
if ( this.doubleBondOnRight ) {
diatomicOxygenMolecule.rotate( -diatomicMoleculeRotationAngle );
diatomicOxygenMolecule.setCenterOfGravityPos( ( this.getInitialAtomCogOffset( this.rightOxygenAtom ).x + this.getInitialAtomCogOffset( this.centerOxygenAtom ).x ) / 2,
diff --git a/js/photon-absorption/view/AtomNode.js b/js/photon-absorption/view/AtomNode.js
index 856c1002..c219479e 100644
--- a/js/photon-absorption/view/AtomNode.js
+++ b/js/photon-absorption/view/AtomNode.js
@@ -31,22 +31,22 @@ define( require => {
Node.call( this );
// Carry this node through the scope in nested functions.
- var self = this;
+ const self = this;
// Instance Data
self.atom = atom; // @private
self.modelViewTransform = modelViewTransform; // @private
// Scale the radius to the modelViewTransform.
- var transformedRadius = modelViewTransform.modelToViewDeltaX( atom.radius );
+ const transformedRadius = modelViewTransform.modelToViewDeltaX( atom.radius );
// Create a color gradient which is used when the molecule enters an excitation state.
- var haloGradientPaint = new RadialGradient( 0, 0, 0, 0, 0, transformedRadius * 2 ).addColorStop( 0, 'yellow' ).addColorStop( 1, 'rgba( 255, 255, 51, 0 )' );
+ const haloGradientPaint = new RadialGradient( 0, 0, 0, 0, 0, transformedRadius * 2 ).addColorStop( 0, 'yellow' ).addColorStop( 1, 'rgba( 255, 255, 51, 0 )' );
this.highlightNode = new Circle( transformedRadius * 2, { fill: haloGradientPaint } ); // @private
// Don't add the highlight halo now - wait until the first time it is used. This is done for performance reasons.
// Represent the atom as a shaded sphere node.
- var atomNode = new ShadedSphereNode( transformedRadius * 2, { mainColor: this.atom.representationColor } );
+ const atomNode = new ShadedSphereNode( transformedRadius * 2, { mainColor: this.atom.representationColor } );
self.addChild( atomNode );
// Link the model position to the position of this node.
diff --git a/js/photon-absorption/view/AtomicBondNode.js b/js/photon-absorption/view/AtomicBondNode.js
index 59d47e93..3ec90ca4 100644
--- a/js/photon-absorption/view/AtomicBondNode.js
+++ b/js/photon-absorption/view/AtomicBondNode.js
@@ -18,10 +18,10 @@ define( require => {
const Vector2 = require( 'DOT/Vector2' );
// constants that control the width of the bond representation with with respect to the average atom radius.
- var BOND_WIDTH_PROPORTION_SINGLE = 0.45;
- var BOND_WIDTH_PROPORTION_DOUBLE = 0.28;
- var BOND_WIDTH_PROPORTION_TRIPLE = 0.24;
- var BOND_COLOR = 'rgb(0, 200, 0)';
+ const BOND_WIDTH_PROPORTION_SINGLE = 0.45;
+ const BOND_WIDTH_PROPORTION_DOUBLE = 0.28;
+ const BOND_WIDTH_PROPORTION_TRIPLE = 0.24;
+ const BOND_COLOR = 'rgb(0, 200, 0)';
/**
* Constructor for an atomic bond node.
@@ -43,7 +43,7 @@ define( require => {
Node.call( this );
// Carry this node through the scope in nested functions.
- var self = this;
+ const self = this;
// Calculate the width to use for the bond representation(s) // @private
@@ -74,10 +74,10 @@ define( require => {
*/
initializeRepresentation: function() {
- var bondWidth; // Width of the line representing this bond. Dependent on the number of bonds between the atoms.
- var bond1; // First bond shared by the atoms.
- var bond2; // Second bond shared by the atoms.
- var bond3; // Third bond shared by the atoms.
+ let bondWidth; // Width of the line representing this bond. Dependent on the number of bonds between the atoms.
+ let bond1; // First bond shared by the atoms.
+ let bond2; // Second bond shared by the atoms.
+ let bond3; // Third bond shared by the atoms.
switch( this.atomicBond.bondCount ) {
case 1:
@@ -123,11 +123,11 @@ define( require => {
*/
updateRepresentation: function() {
- var p1; // Point describing position of one end of the line representing this atomic bond.
- var p2; // Point describing position of the other end of the line representing the atomic bond.
- var offsetVector; // Vector which places the atomic bonds an offset away from the center between the atoms.
- var angle; // An angle used to describe the offset vector.
- var transformedRadius; // A position required to calculate the offset vector.
+ let p1; // Point describing position of one end of the line representing this atomic bond.
+ let p2; // Point describing position of the other end of the line representing the atomic bond.
+ let offsetVector; // Vector which places the atomic bonds an offset away from the center between the atoms.
+ let angle; // An angle used to describe the offset vector.
+ let transformedRadius; // A position required to calculate the offset vector.
switch( this.atomicBond.bondCount ) {
diff --git a/js/photon-absorption/view/EmissionRateControlSliderNode.js b/js/photon-absorption/view/EmissionRateControlSliderNode.js
index ab61e239..22f068dc 100644
--- a/js/photon-absorption/view/EmissionRateControlSliderNode.js
+++ b/js/photon-absorption/view/EmissionRateControlSliderNode.js
@@ -30,15 +30,15 @@ define( require => {
const WavelengthConstants = require( 'MOLECULES_AND_LIGHT/photon-absorption/model/WavelengthConstants' );
// constants
- var THUMB_SIZE = new Dimension2( 10, 18 ); // size of the slider thumb
- var TRACK_SIZE = new Dimension2( 50, 0.25 ); // size of the slider track
- var THUMB_RECTANGLE_WIDTH = 30; // a background rectangle behind the thumb, made visible when the slider has focus
- var THUMB_RECTANGLE_HEIGHT = 45; // a background rectangle behind the thumb, made visible when the slider has focus
+ const THUMB_SIZE = new Dimension2( 10, 18 ); // size of the slider thumb
+ const TRACK_SIZE = new Dimension2( 50, 0.25 ); // size of the slider track
+ const THUMB_RECTANGLE_WIDTH = 30; // a background rectangle behind the thumb, made visible when the slider has focus
+ const THUMB_RECTANGLE_HEIGHT = 45; // a background rectangle behind the thumb, made visible when the slider has focus
// a11y strings
- var lightSourceSliderString = MoleculesAndLightA11yStrings.lightSourceSliderString.value;
+ const lightSourceSliderString = MoleculesAndLightA11yStrings.lightSourceSliderString.value;
// var lightSourceTitlePattern = MoleculesAndLightA11yStrings.lightSourceTitlePattern.value;
- var emissionSliderDescriptionString = MoleculesAndLightA11yStrings.emissionSliderDescriptionString.value;
+ const emissionSliderDescriptionString = MoleculesAndLightA11yStrings.emissionSliderDescriptionString.value;
/**
* Constructor for an emission rate control slider.
@@ -53,14 +53,14 @@ define( require => {
// Supertype constructor
Node.call( this );
- var self = this;
+ const self = this;
this.model = model; // @private
this.color = color; // @private
// Create the slider. Frequency mapped from 0 to 1 so that there is a direct map to PhotonEmitterNode 'on' image
// opacity.
- var sliderRange = new Range( 0, 1 );
- var sliderThumb = new EmissionRateThumbNode();
+ const sliderRange = new Range( 0, 1 );
+ const sliderThumb = new EmissionRateThumbNode();
// var initialFrequency, delta;
this.emissionRateControlSlider = new HSlider( model.emissionFrequencyProperty, sliderRange, {
trackSize: TRACK_SIZE,
@@ -99,7 +99,7 @@ define( require => {
} );
// width of the background rectangle is larger than the slider to accentuate the thumb.
- var backgroundOffset = 4;
+ const backgroundOffset = 4;
this.backgroundRect = new Rectangle(
-THUMB_SIZE.width / 2 - backgroundOffset,
-THUMB_SIZE.height / 4,
@@ -146,7 +146,7 @@ define( require => {
this.emissionRateControlSlider.value = this.model.getSingleTargetFrequencyFromPeriod();
// Update the color of the slider.
- var wavelength = this.model.photonWavelengthProperty.get();
+ const wavelength = this.model.photonWavelengthProperty.get();
if ( wavelength === WavelengthConstants.IR_WAVELENGTH ) {
this.setBackgroundRectColor( PhetColorScheme.RED_COLORBLIND ); // This tested well.
}
@@ -173,8 +173,8 @@ define( require => {
* @private
*/
setBackgroundRectColor: function( baseColor ) {
- var rectHeight = this.emissionRateControlSlider.height;
- var rectWidth = this.emissionRateControlSlider.width;
+ const rectHeight = this.emissionRateControlSlider.height;
+ const rectWidth = this.emissionRateControlSlider.width;
this.backgroundRect.fill = new LinearGradient( 0, 0, rectWidth, rectHeight ).addColorStop( 0, 'rgb(51,51,51)' ).addColorStop( 1, baseColor );
}
@@ -197,7 +197,7 @@ define( require => {
Node.call( this );
// draw the partial octagon shape of the slider.
- var thumbShape = new Shape();
+ const thumbShape = new Shape();
thumbShape.moveTo( 0, 0 ); // Top left corner of the thumb.
thumbShape.horizontalLineTo( THUMB_SIZE.width * 0.75 );
thumbShape.lineTo( THUMB_SIZE.width, THUMB_SIZE.height * 0.33 );
@@ -213,7 +213,7 @@ define( require => {
} );
// supertype constructor
- var thumbPath = new Path( thumbShape, {
+ const thumbPath = new Path( thumbShape, {
lineWidth: 1,
lineJoin: 'bevel',
stroke: 'black',
@@ -226,7 +226,7 @@ define( require => {
this.addChild( thumbPath );
// draw three lines along the vertical of the thumbNode.
- for ( var n = 1; n < 4; n++ ) {
+ for ( let n = 1; n < 4; n++ ) {
thumbPath.addChild( new Path(
Shape.lineSegment(
n * THUMB_SIZE.width / 5,
@@ -240,7 +240,7 @@ define( require => {
}
// highlight thumb on pointer over
- var buttonListener = new ButtonListener( {
+ const buttonListener = new ButtonListener( {
over: function( event ) {
thumbPath.fill = 'rgb(80,250,255)';
},
diff --git a/js/photon-absorption/view/MoleculeNode.js b/js/photon-absorption/view/MoleculeNode.js
index 4a314ba1..1dcebd9a 100644
--- a/js/photon-absorption/view/MoleculeNode.js
+++ b/js/photon-absorption/view/MoleculeNode.js
@@ -29,31 +29,31 @@ define( require => {
Node.call( this );
// Carry this node through the scope in nested functions.
- var self = this;
+ const self = this;
this.modelViewTransform = modelViewTransform; // @private
// Instance Data
- var atomLayer = new Node();
- var bondLayer = new Node();
+ const atomLayer = new Node();
+ const bondLayer = new Node();
self.addChild( bondLayer ); // Order the bond layer first so that atomic bonds are behind atoms in view
self.addChild( atomLayer );
// Create nodes and add the atoms which compose this molecule to the atomLayer.
- for ( var atom = 0; atom < molecule.getAtoms().length; atom++ ) {
+ for ( let atom = 0; atom < molecule.getAtoms().length; atom++ ) {
this.atomNode = new AtomNode( molecule.getAtoms()[ atom ], self.modelViewTransform );
atomLayer.addChild( this.atomNode );
}
// Create and add the atomic bonds which form the structure of this molecule to the bondLayer
- var atomicBonds = molecule.getAtomicBonds();
- for ( var i = 0; i < atomicBonds.length; i++ ) {
+ const atomicBonds = molecule.getAtomicBonds();
+ for ( let i = 0; i < atomicBonds.length; i++ ) {
bondLayer.addChild( new AtomicBondNode( atomicBonds[ i ], this.modelViewTransform ) );
}
// Link the high energy state to the property in the model.
molecule.highElectronicEnergyStateProperty.link( function() {
- for ( var i = 0; i < atomLayer.children.length; i++ ) {
- var atomNode = atomLayer.getChildAt( i );
+ for ( let i = 0; i < atomLayer.children.length; i++ ) {
+ const atomNode = atomLayer.getChildAt( i );
atomNode.setHighlighted( molecule.highElectronicEnergyStateProperty.get() );
}
diff --git a/js/photon-absorption/view/PhotonEmitterNode.js b/js/photon-absorption/view/PhotonEmitterNode.js
index 79664967..eaa66197 100644
--- a/js/photon-absorption/view/PhotonEmitterNode.js
+++ b/js/photon-absorption/view/PhotonEmitterNode.js
@@ -45,13 +45,13 @@ define( require => {
Node.call( this );
// carry this through scope
- var self = this;
+ const self = this;
this.model = model; // @private
// update the photon emitter upon changes to the photon wavelength
model.photonWavelengthProperty.link( function( photonWavelength ) {
- var emitterTandemName = WavelengthConstants.getTandemName( photonWavelength );
+ const emitterTandemName = WavelengthConstants.getTandemName( photonWavelength );
self.updateImage( width, photonWavelength, model.emissionFrequencyProperty.value, tandem, emitterTandemName );
} );
diff --git a/js/photon-absorption/view/PhotonNode.js b/js/photon-absorption/view/PhotonNode.js
index 625f2c7f..9968c2eb 100644
--- a/js/photon-absorption/view/PhotonNode.js
+++ b/js/photon-absorption/view/PhotonNode.js
@@ -24,7 +24,7 @@ define( require => {
const thin2Image = require( 'image!MOLECULES_AND_LIGHT/thin2.png' );
// Map of photon wavelengths to visual images used for representing them.
- var mapWavelengthToImageName = {};
+ const mapWavelengthToImageName = {};
mapWavelengthToImageName[ WavelengthConstants.MICRO_WAVELENGTH ] = microwavePhotonImage;
mapWavelengthToImageName[ WavelengthConstants.IR_WAVELENGTH ] = photon660Image;
mapWavelengthToImageName[ WavelengthConstants.VISIBLE_WAVELENGTH ] = thin2Image;
@@ -43,7 +43,7 @@ define( require => {
Node.call( this );
// Carry this node through the scope in nested functions.
- var self = this;
+ const self = this;
// @private
this.photon = photon;
@@ -51,7 +51,7 @@ define( require => {
// Lookup the image file that corresponds to the wavelength and add a centered image.
assert && assert( mapWavelengthToImageName.hasOwnProperty( this.photon.wavelength ) );
- var photonImage = new Image( mapWavelengthToImageName[ this.photon.wavelength ] );
+ const photonImage = new Image( mapWavelengthToImageName[ this.photon.wavelength ] );
this.addChild( photonImage );