Skip to content

Commit

Permalink
ES6 module migration, see phetsims/chipper#875
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Feb 27, 2020
1 parent aa00de5 commit b56953e
Showing 1 changed file with 49 additions and 53 deletions.
102 changes: 49 additions & 53 deletions js/common/view/LevelSupportColumnNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,61 @@
*
* @author John Blanco
*/
define( require => {
'use strict';

// modules
const balancingAct = require( 'BALANCING_ACT/balancingAct' );
const ColumnState = require( 'BALANCING_ACT/common/model/ColumnState' );
const inherit = require( 'PHET_CORE/inherit' );
const LinearGradient = require( 'SCENERY/util/LinearGradient' );
const Node = require( 'SCENERY/nodes/Node' );
const Path = require( 'SCENERY/nodes/Path' );
const Rectangle = require( 'SCENERY/nodes/Rectangle' );
import inherit from '../../../../phet-core/js/inherit.js';
import Node from '../../../../scenery/js/nodes/Node.js';
import Path from '../../../../scenery/js/nodes/Path.js';
import Rectangle from '../../../../scenery/js/nodes/Rectangle.js';
import LinearGradient from '../../../../scenery/js/util/LinearGradient.js';
import balancingAct from '../../balancingAct.js';
import ColumnState from '../model/ColumnState.js';

/**
* @param modelViewTransform
* @param levelSupportColumn
* @param columnState
* @constructor
*/
function LevelSupportColumnNode( modelViewTransform, levelSupportColumn, columnState ) {
Node.call( this );
const self = this;

// Create and add the main body of the column.
const transformedColumnShape = modelViewTransform.modelToViewShape( levelSupportColumn.shape );
const mainBodyGradient = new LinearGradient( transformedColumnShape.bounds.minX, 0, transformedColumnShape.bounds.maxX, 0 ).addColorStop( 0, 'rgb( 150, 150, 150 )' ).addColorStop( 0.25, 'rgb( 230, 230, 230 )' ).addColorStop( 0.65, 'rgb( 150, 150, 150 )' ).addColorStop( 1, 'rgb( 200, 200, 200 )' );
/**
* @param modelViewTransform
* @param levelSupportColumn
* @param columnState
* @constructor
*/
function LevelSupportColumnNode( modelViewTransform, levelSupportColumn, columnState ) {
Node.call( this );
const self = this;

const columnNode = new Path( transformedColumnShape,
{
fill: mainBodyGradient,
stroke: 'black',
lineWidth: 1
} );
self.addChild( columnNode );
// Create and add the main body of the column.
const transformedColumnShape = modelViewTransform.modelToViewShape( levelSupportColumn.shape );
const mainBodyGradient = new LinearGradient( transformedColumnShape.bounds.minX, 0, transformedColumnShape.bounds.maxX, 0 ).addColorStop( 0, 'rgb( 150, 150, 150 )' ).addColorStop( 0.25, 'rgb( 230, 230, 230 )' ).addColorStop( 0.65, 'rgb( 150, 150, 150 )' ).addColorStop( 1, 'rgb( 200, 200, 200 )' );

// Create and add the column support.
const supportWidth = transformedColumnShape.bounds.width * 1.3; // Empirically determined.
const supportHeight = transformedColumnShape.bounds.height * 0.15; // Empirically determined.
const supportGradient = new LinearGradient( transformedColumnShape.bounds.centerX - supportWidth / 2, 0, transformedColumnShape.bounds.centerX + supportWidth / 2, 0 ).addColorStop( 0, 'rgb( 150, 150, 150 )' ).addColorStop( 0.25, 'rgb( 210, 210, 210 )' ).addColorStop( 0.65, 'rgb( 150, 150, 150 )' ).addColorStop( 1, 'rgb( 170, 170, 170 )' );
const columnSupportNode = new Rectangle(
transformedColumnShape.bounds.centerX - supportWidth / 2,
transformedColumnShape.bounds.maxY - supportHeight,
supportWidth,
supportHeight,
3,
3,
{
fill: supportGradient,
stroke: 'black',
lineWidth: 1
} );
self.addChild( columnSupportNode );
const columnNode = new Path( transformedColumnShape,
{
fill: mainBodyGradient,
stroke: 'black',
lineWidth: 1
} );
self.addChild( columnNode );

columnState.link( function( state ) {
self.visible = state === ColumnState.DOUBLE_COLUMNS;
// Create and add the column support.
const supportWidth = transformedColumnShape.bounds.width * 1.3; // Empirically determined.
const supportHeight = transformedColumnShape.bounds.height * 0.15; // Empirically determined.
const supportGradient = new LinearGradient( transformedColumnShape.bounds.centerX - supportWidth / 2, 0, transformedColumnShape.bounds.centerX + supportWidth / 2, 0 ).addColorStop( 0, 'rgb( 150, 150, 150 )' ).addColorStop( 0.25, 'rgb( 210, 210, 210 )' ).addColorStop( 0.65, 'rgb( 150, 150, 150 )' ).addColorStop( 1, 'rgb( 170, 170, 170 )' );
const columnSupportNode = new Rectangle(
transformedColumnShape.bounds.centerX - supportWidth / 2,
transformedColumnShape.bounds.maxY - supportHeight,
supportWidth,
supportHeight,
3,
3,
{
fill: supportGradient,
stroke: 'black',
lineWidth: 1
} );
}
self.addChild( columnSupportNode );

balancingAct.register( 'LevelSupportColumnNode', LevelSupportColumnNode );
columnState.link( function( state ) {
self.visible = state === ColumnState.DOUBLE_COLUMNS;
} );
}

return inherit( Node, LevelSupportColumnNode );
} );
balancingAct.register( 'LevelSupportColumnNode', LevelSupportColumnNode );

inherit( Node, LevelSupportColumnNode );
export default LevelSupportColumnNode;

0 comments on commit b56953e

Please sign in to comment.