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 authored and marlitas committed Jun 22, 2022
1 parent df72a99 commit 8d18f77
Showing 1 changed file with 41 additions and 44 deletions.
85 changes: 41 additions & 44 deletions js/common/view/TriangleNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,44 @@
*
* @author Sam Reid (PhET Interactive Simulations)
*/
define( require => {
'use strict';

// modules
const inherit = require( 'PHET_CORE/inherit' );
const Matrix3 = require( 'DOT/Matrix3' );
const merge = require( 'PHET_CORE/merge' );
const Path = require( 'SCENERY/nodes/Path' );
const proportionPlayground = require( 'PROPORTION_PLAYGROUND/proportionPlayground' );
const Shape = require( 'KITE/Shape' );
const Side = require( 'PROPORTION_PLAYGROUND/common/model/Side' );

// constants
const TRIANGLE_LENGTH = 17;
const TRIANGLE_ALTITUDE = 10;
const LEFT_TRIANGLE_SHAPE = new Shape().moveTo( 0, 0 )
.lineTo( TRIANGLE_ALTITUDE, TRIANGLE_LENGTH / 2 )
.lineTo( 0, TRIANGLE_LENGTH )
.lineTo( 0, 0 );
const RIGHT_TRIANGLE_SHAPE = LEFT_TRIANGLE_SHAPE.transformed( Matrix3.scaling( -1, 1 ) );

/**
* @constructor
* @extends {Path}
*
* @param {Side} side - Side.LEFT or Side.RIGHT
* @param {Object} [options]
*/
function TriangleNode( side, options ) {
assert && assert( Side.isSide( side ), 'Side should be Side.LEFT or Side.RIGHT' );

// defaults
options = merge( {
stroke: 'black',
lineWidth: 1
}, options );

Path.call( this, side === Side.LEFT ? LEFT_TRIANGLE_SHAPE : RIGHT_TRIANGLE_SHAPE, options );
}

proportionPlayground.register( 'TriangleNode', TriangleNode );

return inherit( Path, TriangleNode );
} );

import Matrix3 from '../../../../dot/js/Matrix3.js';
import Shape from '../../../../kite/js/Shape.js';
import inherit from '../../../../phet-core/js/inherit.js';
import merge from '../../../../phet-core/js/merge.js';
import Path from '../../../../scenery/js/nodes/Path.js';
import proportionPlayground from '../../proportionPlayground.js';
import Side from '../model/Side.js';

// constants
const TRIANGLE_LENGTH = 17;
const TRIANGLE_ALTITUDE = 10;
const LEFT_TRIANGLE_SHAPE = new Shape().moveTo( 0, 0 )
.lineTo( TRIANGLE_ALTITUDE, TRIANGLE_LENGTH / 2 )
.lineTo( 0, TRIANGLE_LENGTH )
.lineTo( 0, 0 );
const RIGHT_TRIANGLE_SHAPE = LEFT_TRIANGLE_SHAPE.transformed( Matrix3.scaling( -1, 1 ) );

/**
* @constructor
* @extends {Path}
*
* @param {Side} side - Side.LEFT or Side.RIGHT
* @param {Object} [options]
*/
function TriangleNode( side, options ) {
assert && assert( Side.isSide( side ), 'Side should be Side.LEFT or Side.RIGHT' );

// defaults
options = merge( {
stroke: 'black',
lineWidth: 1
}, options );

Path.call( this, side === Side.LEFT ? LEFT_TRIANGLE_SHAPE : RIGHT_TRIANGLE_SHAPE, options );
}

proportionPlayground.register( 'TriangleNode', TriangleNode );

inherit( Path, TriangleNode );
export default TriangleNode;

0 comments on commit 8d18f77

Please sign in to comment.