-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create chocolate bar container, see: #57
- Loading branch information
Showing
3 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2022, University of Colorado Boulder | ||
|
||
/** | ||
* TODO | ||
* | ||
* @author Marla Schulz (PhET Interactive Simulations) | ||
* @author Sam Reid (PhET Interactive Simulations) | ||
*/ | ||
|
||
|
||
import optionize from '../../../../phet-core/js/optionize.js'; | ||
import EmptyObjectType from '../../../../phet-core/js/types/EmptyObjectType.js'; | ||
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js'; | ||
import { Node, NodeOptions } from '../../../../scenery/js/imports.js'; | ||
import meanShareAndBalance from '../../meanShareAndBalance.js'; | ||
import Chocolate from '../model/Chocolate.js'; | ||
import ChocolateBarRectangle from './ChocolateBarRectangle.js'; | ||
import MeanShareAndBalanceConstants from '../../common/MeanShareAndBalanceConstants.js'; | ||
|
||
type ChocolateBarsContainerNodeOptions = StrictOmit<NodeOptions, 'x' | 'y' | 'left' | 'right' | 'top' | 'bottom'> | ||
|
||
export default class ChocolateBarsContainerNode extends Node { | ||
public constructor( chocolateModel: Chocolate, providedOptions?: ChocolateBarsContainerNodeOptions ) { | ||
const options = optionize<ChocolateBarsContainerNodeOptions, EmptyObjectType, NodeOptions>()( { | ||
x: chocolateModel.x, | ||
y: chocolateModel.y | ||
}, providedOptions ); | ||
|
||
const chocolateBars = []; | ||
for ( let i = 0; i < chocolateModel.chocolateBarsNumberProperty.value; i++ ) { | ||
const chocolateBar = new ChocolateBarRectangle(); | ||
chocolateBar.y = ( MeanShareAndBalanceConstants.CHOCOLATE_HEIGHT + 5 ) * i; | ||
chocolateBars.push( chocolateBar ); | ||
} | ||
|
||
options.children = chocolateBars; | ||
super( options ); | ||
} | ||
} | ||
|
||
meanShareAndBalance.register( 'ChocolateBarsContainerNode', ChocolateBarsContainerNode ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters