// Copyright 2016-2018, University of Colorado Boulder

/**
 * model of a cloud that can block energy coming from the sun
 *
 * @author  John Blanco
 * @author  Andrew Adare
 */
define( function( require ) {
  'use strict';

  // modules
  var energyFormsAndChanges = require( 'ENERGY_FORMS_AND_CHANGES/energyFormsAndChanges' );
  var inherit = require( 'PHET_CORE/inherit' );
  var NumberProperty = require( 'AXON/NumberProperty' );
  var Shape = require( 'KITE/Shape' );

  // constants
  var WIDTH = 0.035; // In meters, though obviously not to scale.  Empirically determined.
  var HEIGHT = WIDTH * 0.55; // determined from the approximate aspect ratio of the image

  /**
   * @param {Vector2} offsetFromParent
   * @param {Property.<Vector2>} parentPositionProperty
   * @constructor
   */
  function Cloud( offsetFromParent, parentPositionProperty ) {
    var self = this;

    // @public {NumberProperty} - existence strength, which basically translates to opacity, of the cloud
    this.existenceStrengthProperty = new NumberProperty( 1.0 );

    // @public (read-only) {number} - offset position for this cloud
    this.offsetFromParent = offsetFromParent;

    // @private {number} - used to calculate this cloud's position
    this.parentPositionProperty = parentPositionProperty;

    this.cloudEllipse = null;

    this.parentPositionProperty.link( function( parentPosition ) {
      var center = parentPosition.plus( self.offsetFromParent );
      self.cloudEllipse = Shape.ellipse( center.x, center.y, WIDTH / 2, HEIGHT / 2, 0, 0, 0, false );
    } );
  }

  energyFormsAndChanges.register( 'Cloud', Cloud );

  return inherit( Object, Cloud, {

    /**
     * return ellipse with size of this cloud
     * @returns {Shape.ellipse} - ellipse with axes sized to width and height of cloud
     * @public
     */
    getCloudAbsorptionReflectionShape: function() {
      return this.cloudEllipse;
    },

    /**
     * @returns {Vector2} Center position of cloud
     * @public
     */
    getCenterPosition: function() {
      return this.parentPositionProperty.get().plus( this.offsetFromParent );
    }

  }, {

    // statics
    WIDTH: WIDTH,
    HEIGHT: HEIGHT
  } );
} );


@@ -18,9 +18,9 @@
 -201
-8
+9
 , Un
@@ -178,26 +178,16 @@
 %0Adefine(
- function(
  require
@@ -187,17 +187,18 @@
 require 
-)
+=%3E
  %7B%0A  'us
@@ -224,19 +224,21 @@
 dules%0A  
-var
+const
  energyF
@@ -321,59 +321,13 @@
 ;%0A  
-var inherit = require( 'PHET_CORE/inherit' );%0A  var
+const
  Num
@@ -376,19 +376,21 @@
 y' );%0A  
-var
+const
  Shape =
@@ -433,19 +433,21 @@
 tants%0A  
-var
+const
  WIDTH =
@@ -526,19 +526,21 @@
 ined.%0A  
-var
+const
  HEIGHT 
@@ -617,16 +617,35 @@
  image%0A%0A
+  class Cloud %7B%0A%0A  
   /**%0A  
@@ -641,24 +641,26 @@
 %0A    /**%0A   
+  
 * @param %7BVe
@@ -683,16 +683,18 @@
 mParent%0A
+  
    * @pa
@@ -744,19 +744,25 @@
 erty%0A   
-* @
+  */%0A    
 construc
@@ -768,31 +768,8 @@
 ctor
-%0A   */%0A  function Cloud
 ( of
@@ -815,30 +815,11 @@
 ) %7B%0A
+%0A
   
-  var self = this;%0A%0A
     
@@ -920,24 +920,26 @@
 e cloud%0A    
+  
 this.existen
@@ -987,24 +987,26 @@
 1.0 );%0A%0A    
+  
 // @public (
@@ -1058,24 +1058,26 @@
 s cloud%0A    
+  
 this.offsetF
@@ -1107,16 +1107,18 @@
 arent;%0A%0A
+  
     // @
@@ -1176,24 +1176,26 @@
 osition%0A    
+  
 this.parentP
@@ -1237,24 +1237,26 @@
 perty;%0A%0A    
+  
 this.cloudEl
@@ -1270,24 +1270,26 @@
  null;%0A%0A    
+  
 this.parentP
@@ -1309,26 +1309,16 @@
 ty.link(
- function(
  parentP
@@ -1325,17 +1325,18 @@
 osition 
-)
+=%3E
  %7B%0A     
@@ -1340,11 +1340,15 @@
     
-var
+  const
  cen
@@ -1374,20 +1374,20 @@
 n.plus( 
-self
+this
 .offsetF
@@ -1409,12 +1409,14 @@
     
-self
+  this
 .clo
@@ -1511,105 +1511,20 @@
     
-%7D );%0A  %7D%0A%0A  energyFormsAndChanges.register( 'Cloud', Cloud
+  %7D
  );%0A
-%0A
   
-return inherit( Object, Cloud, %7B
+  %7D
 %0A%0A  
@@ -1722,26 +1722,16 @@
 ionShape
-: function
 () %7B%0A   
@@ -1764,17 +1764,16 @@
 e;%0A    %7D
-,
 %0A%0A    /*
@@ -1873,18 +1873,8 @@
 tion
-: function
 () %7B
@@ -1966,15 +1966,10 @@
 %0A  %7D
-, %7B%0A%0A  
+%0A%0A
   //
@@ -1983,46 +1983,110 @@
 s%0A  
-  
+Cloud.
 WIDTH
-:
+ =
  WIDTH
-,%0A    
+;%0A  Cloud.
 HEIGHT
-:
+ =
  HEIGHT
+;%0A
 %0A  
-%7D
+return energyFormsAndChanges.register( 'Cloud', Cloud
  );%0A

Convert to ES6, see https://github.com/phetsims/energy-forms-and-changes/issues/211