-
Notifications
You must be signed in to change notification settings - Fork 7
/
MySolutionScreen.js
77 lines (62 loc) · 2.53 KB
/
MySolutionScreen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright 2014-2019, University of Colorado Boulder
/**
* The 'My Solution' screen.
*
* @author Chris Malley (PixelZoom, Inc.)
*/
define( require => {
'use strict';
// modules
const ABSColors = require( 'ACID_BASE_SOLUTIONS/common/ABSColors' );
const acidBaseSolutions = require( 'ACID_BASE_SOLUTIONS/acidBaseSolutions' );
const inherit = require( 'PHET_CORE/inherit' );
const MoleculeFactory = require( 'ACID_BASE_SOLUTIONS/common/view/MoleculeFactory' );
const MySolutionModel = require( 'ACID_BASE_SOLUTIONS/mysolution/model/MySolutionModel' );
const MySolutionScreenView = require( 'ACID_BASE_SOLUTIONS/mysolution/view/MySolutionScreenView' );
const Node = require( 'SCENERY/nodes/Node' );
const Property = require( 'AXON/Property' );
const Rectangle = require( 'SCENERY/nodes/Rectangle' );
const Screen = require( 'JOIST/Screen' );
// strings
const screenMySolutionString = require( 'string!ACID_BASE_SOLUTIONS/screen.mySolution' );
/**
* @constructor
*/
function MySolutionScreen( tandem ) {
const options = {
name: screenMySolutionString,
backgroundColorProperty: new Property( ABSColors.SCREEN_BACKGROUND ),
homeScreenIcon: createScreenIcon(),
tandem: tandem
};
Screen.call( this,
function() { return new MySolutionModel(); },
function( model ) { return new MySolutionScreenView( model ); },
options );
}
acidBaseSolutions.register( 'MySolutionScreen', MySolutionScreen );
/**
* Creates the icon for this screen.
* @returns {Node}
*/
var createScreenIcon = function() {
const width = Screen.MINIMUM_HOME_SCREEN_ICON_SIZE.width;
const height = Screen.MINIMUM_HOME_SCREEN_ICON_SIZE.height;
const h3oNode = MoleculeFactory.H3O();
const ohNode = MoleculeFactory.OH();
// Uniformly scale the molecules to make them fill the available space.
const xSpace = 0.06 * width; // horizontal space around the molecules
const maxWidth = Math.max( h3oNode.width, ohNode.width );
const moleculeScale = 0.5 * ( width - 3 * xSpace ) / maxWidth;
h3oNode.setScaleMagnitude( moleculeScale, moleculeScale );
ohNode.setScaleMagnitude( moleculeScale, moleculeScale );
// position the molecules
h3oNode.left = xSpace;
ohNode.right = width - xSpace;
h3oNode.centerY = height / 2;
ohNode.centerY = h3oNode.centerY;
const background = new Rectangle( 0, 0, width, height, { fill: 'white' } );
return new Node( { children: [ background, h3oNode, ohNode ] } );
};
return inherit( Screen, MySolutionScreen );
} );