<commit_before>// Copyright 2016-2018, University of Colorado Boulder

/**
 * a model of a drop of water, generally used to create a stream of water coming from, say, a faucet
 *
 * @author <NAME>
 * @author <NAME>
 * @author <NAME> (PhET Interactive Simulations)
 */
define( function( require ) {
  'use strict';

  // modules
  var Dimension2 = require( 'DOT/Dimension2' );
  var energyFormsAndChanges = require( 'ENERGY_FORMS_AND_CHANGES/energyFormsAndChanges' );
  var inherit = require( 'PHET_CORE/inherit' );
  var Property = require( 'AXON/Property' );

  // the following constant is used to adjust the way in which the drop elongates as its velocity increases
  var WIDTH_CHANGE_TWEAK_FACTOR = 0.05;

  /**
   * @param {Vector2} initialPosition - (x,y) position in model space
   * @param {Vector2} initialVelocity - 2D velocity at initialization
   * @param {Dimension2} size - droplet dimensions
   */
  function WaterDrop( initialPosition, initialVelocity, size ) {

    var self = this;

    // @public {Vector2} - after being transformed to view coordinates, this position is the distance from the faucet head
    this.position = initialPosition;

    // @public {Property.<Vector2>}
    this.velocityProperty = new Property( initialVelocity );

    // @public (read-only) {Dimension2}
    this.size = size;

    // adjust the size as the velocity changes, mimicking how water drops thin out as they fall through air
    this.velocityProperty.link( function( velocity ) {
      var newWidth = ( 1 / ( 1 + velocity.magnitude() * WIDTH_CHANGE_TWEAK_FACTOR ) ) * self.size.width;
      var newHeight = ( self.size.height * self.size.width ) / newWidth;
      self.size.set( new Dimension2( newWidth, newHeight ) );
    } );
  }

  energyFormsAndChanges.register( 'WaterDrop', WaterDrop );

  return inherit( Object, WaterDrop );
} );<commit_msg>Convert to ES6, see https://github.com/phetsims/energy-forms-and-changes/issues/211<commit_after>// Copyright 2016-2019, University of Colorado Boulder

/**
 * a model of a drop of water, generally used to create a stream of water coming from, say, a faucet
 *
 * @author <NAME>
 * @author <NAME>
 * @author <NAME> (PhET Interactive Simulations)
 */
define( require => {
  'use strict';

  // modules
  const Dimension2 = require( 'DOT/Dimension2' );
  const energyFormsAndChanges = require( 'ENERGY_FORMS_AND_CHANGES/energyFormsAndChanges' );
  const Property = require( 'AXON/Property' );

  // the following constant is used to adjust the way in which the drop elongates as its velocity increases
  const WIDTH_CHANGE_TWEAK_FACTOR = 0.05;

  class WaterDrop {

    /**
     * @param {Vector2} initialPosition - (x,y) position in model space
     * @param {Vector2} initialVelocity - 2D velocity at initialization
     * @param {Dimension2} size - droplet dimensions
     */
    constructor( initialPosition, initialVelocity, size ) {

      // @public {Vector2} - after being transformed to view coordinates, this position is the distance from the faucet head
      this.position = initialPosition;

      // @public {Property.<Vector2>}
      this.velocityProperty = new Property( initialVelocity );

      // @public (read-only) {Dimension2}
      this.size = size;

      // adjust the size as the velocity changes, mimicking how water drops thin out as they fall through air
      this.velocityProperty.link( velocity => {
        const newWidth = ( 1 / ( 1 + velocity.magnitude() * WIDTH_CHANGE_TWEAK_FACTOR ) ) * this.size.width;
        const newHeight = ( this.size.height * this.size.width ) / newWidth;
        this.size.set( new Dimension2( newWidth, newHeight ) );
      } );
    }
  }

  return energyFormsAndChanges.register( 'WaterDrop', WaterDrop );
} );
{'fraction_non_alphanumeric': 0.10592652185572539, 'fraction_numerical': 0.013408420488066506, 'mean_word_length': 3.408983451536643, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7460724', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1080, 'n_words': 357}