phetsims / color-vision

"Color Vision" is an educational simulation in HTML5, by PhET Interactive Simulations.
http://phet.colorado.edu/en/simulation/color-vision
GNU General Public License v3.0
1 stars 7 forks source link

Factor out code between step and manualStep #38

Closed samreid closed 10 years ago

samreid commented 10 years ago

In RGBModel there is this code:

      step: function( dt ) {
        if ( this.play ) {
          if ( dt > Constants.MAX_DT || dt <= 0 ) {
            dt = 1.0 / 60.0;
          }
          this.redBeam.updateAnimationFrame( dt );
          this.greenBeam.updateAnimationFrame( dt );
          this.blueBeam.updateAnimationFrame( dt );
        }
      },

      // step one frame, assuming 60fps
      manualStep: function() {
        this.redBeam.updateAnimationFrame( 1 / 60 );
        this.greenBeam.updateAnimationFrame( 1 / 60 );
        this.blueBeam.updateAnimationFrame( 1 / 60 );
      },

I recommend factoring out a function stepBeams that can be called by manualStep and step.

aaronsamuel137 commented 10 years ago

Done. Assigning to @samreid for review

samreid commented 10 years ago

Looks great, thanks! Closing.