Skip to content

Commit

Permalink
strawman screen icons, #28
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jan 14, 2024
1 parent c721440 commit 0a9fc7c
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 25 deletions.
16 changes: 10 additions & 6 deletions js/electromagnet/ElectromagnetScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import ElectromagnetScreenView from './view/ElectromagnetScreenView.js';
import FaradaysElectromagneticLabStrings from '../FaradaysElectromagneticLabStrings.js';
import FELColors from '../common/FELColors.js';
import ScreenIcon from '../../../joist/js/ScreenIcon.js';
import { Rectangle } from '../../../scenery/js/imports.js';
import { Image } from '../../../scenery/js/imports.js';
import Tandem from '../../../tandem/js/Tandem.js';
import { combineOptions } from '../../../phet-core/js/optionize.js';
import FELConstants from '../common/FELConstants.js';
import FELKeyboardHelpContent from '../common/view/FELKeyboardHelpContent.js';
import battery_png from '../../images/battery_png.js';

export default class ElectromagnetScreen extends Screen<ElectromagnetModel, ElectromagnetScreenView> {

Expand All @@ -27,19 +28,22 @@ export default class ElectromagnetScreen extends Screen<ElectromagnetModel, Elec
model => new ElectromagnetScreenView( model, tandem.createTandem( 'view' ) ),
combineOptions<ScreenOptions>( {}, FELConstants.SCREEN_OPTIONS, {
name: FaradaysElectromagneticLabStrings.screen.electromagnetStringProperty,
homeScreenIcon: createHomeScreenIcon(),
homeScreenIcon: createScreenIcon(),
createKeyboardHelpNode: () => new FELKeyboardHelpContent(),
tandem: tandem
}
) );
}
}

//TODO https://github.com/phetsims/faradays-electromagnetic-lab/issues/28 screen icon
function createHomeScreenIcon(): ScreenIcon {
return new ScreenIcon( new Rectangle( 0, 0, 1, 1 ), {
/**
* Creates the icon for this screen.
*/
function createScreenIcon(): ScreenIcon {
const batteryImage = new Image( battery_png );
return new ScreenIcon( batteryImage, {
fill: FELColors.screenBackgroundColorProperty,
maxIconWidthProportion: 1,
maxIconWidthProportion: 0.75,
maxIconHeightProportion: 1
} );
}
Expand Down
36 changes: 30 additions & 6 deletions js/generator/GeneratorScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ import GeneratorScreenView from './view/GeneratorScreenView.js';
import FaradaysElectromagneticLabStrings from '../FaradaysElectromagneticLabStrings.js';
import FELColors from '../common/FELColors.js';
import ScreenIcon from '../../../joist/js/ScreenIcon.js';
import { Rectangle } from '../../../scenery/js/imports.js';
import Tandem from '../../../tandem/js/Tandem.js';
import { Image, Node } from '../../../scenery/js/imports.js';
import { combineOptions } from '../../../phet-core/js/optionize.js';
import FELConstants from '../common/FELConstants.js';
import FELKeyboardHelpContent from '../common/view/FELKeyboardHelpContent.js';
import waterWheel_png from '../../images/waterWheel_png.js';
import BarMagnet from '../common/model/BarMagnet.js';
import BarMagnetNode from '../common/view/BarMagnetNode.js';

export default class GeneratorScreen extends Screen<GeneratorModel, GeneratorScreenView> {

Expand All @@ -27,20 +30,41 @@ export default class GeneratorScreen extends Screen<GeneratorModel, GeneratorScr
model => new GeneratorScreenView( model, tandem.createTandem( 'view' ) ),
combineOptions<ScreenOptions>( {}, FELConstants.SCREEN_OPTIONS, {
name: FaradaysElectromagneticLabStrings.screen.generatorStringProperty,
homeScreenIcon: createHomeScreenIcon(),
homeScreenIcon: createScreenIcon(),
createKeyboardHelpNode: () => new FELKeyboardHelpContent(),
tandem: tandem
}
) );
}
}

//TODO https://github.com/phetsims/faradays-electromagnetic-lab/issues/28 screen icon
function createHomeScreenIcon(): ScreenIcon {
return new ScreenIcon( new Rectangle( 0, 0, 1, 1 ), {
/**
* Creates the icon for this screen.
*/
function createScreenIcon(): ScreenIcon {

const waterWheelImage = new Image( waterWheel_png );

const barMagnet = new BarMagnet( {
tandem: Tandem.OPT_OUT
} );

const barMagnetNode = new BarMagnetNode( barMagnet, {
isMovable: false,
tandem: Tandem.OPT_OUT
} );

barMagnetNode.setScaleMagnitude( 0.95 * waterWheelImage.width / barMagnetNode.width );
barMagnetNode.center = waterWheelImage.center;

const iconNode = new Node( {
children: [ waterWheelImage, barMagnetNode ]
} );

return new ScreenIcon( iconNode, {
fill: FELColors.screenBackgroundColorProperty,
maxIconWidthProportion: 1,
maxIconHeightProportion: 1
maxIconHeightProportion: 0.9
} );
}

Expand Down
16 changes: 10 additions & 6 deletions js/pickup-coil/PickupCoilScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import PickupCoilScreenView from './view/PickupCoilScreenView.js';
import FaradaysElectromagneticLabStrings from '../FaradaysElectromagneticLabStrings.js';
import FELColors from '../common/FELColors.js';
import ScreenIcon from '../../../joist/js/ScreenIcon.js';
import { Rectangle } from '../../../scenery/js/imports.js';
import { Image } from '../../../scenery/js/imports.js';
import Tandem from '../../../tandem/js/Tandem.js';
import { combineOptions } from '../../../phet-core/js/optionize.js';
import FELConstants from '../common/FELConstants.js';
import FELKeyboardHelpContent from '../common/view/FELKeyboardHelpContent.js';
import lightBulbOn_png from '../../../scenery-phet/mipmaps/lightBulbOn_png.js';

export default class PickupCoilScreen extends Screen<PickupCoilModel, PickupCoilScreenView> {

Expand All @@ -27,20 +28,23 @@ export default class PickupCoilScreen extends Screen<PickupCoilModel, PickupCoil
model => new PickupCoilScreenView( model, tandem.createTandem( 'view' ) ),
combineOptions<ScreenOptions>( {}, FELConstants.SCREEN_OPTIONS, {
name: FaradaysElectromagneticLabStrings.screen.pickupCoilStringProperty,
homeScreenIcon: createHomeScreenIcon(),
homeScreenIcon: createScreenIcon(),
createKeyboardHelpNode: () => new FELKeyboardHelpContent(),
tandem: tandem
}
) );
}
}

//TODO https://github.com/phetsims/faradays-electromagnetic-lab/issues/28 screen icon
function createHomeScreenIcon(): ScreenIcon {
return new ScreenIcon( new Rectangle( 0, 0, 1, 1 ), {
/**
* Creates the icon for this screen.
*/
function createScreenIcon(): ScreenIcon {
const lightBulbImage = new Image( lightBulbOn_png );
return new ScreenIcon( lightBulbImage, {
fill: FELColors.screenBackgroundColorProperty,
maxIconWidthProportion: 1,
maxIconHeightProportion: 1
maxIconHeightProportion: 0.85
} );
}

Expand Down
24 changes: 17 additions & 7 deletions js/transformer/TransformerScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import TransformerScreenView from './view/TransformerScreenView.js';
import FaradaysElectromagneticLabStrings from '../FaradaysElectromagneticLabStrings.js';
import FELColors from '../common/FELColors.js';
import ScreenIcon from '../../../joist/js/ScreenIcon.js';
import { Rectangle } from '../../../scenery/js/imports.js';
import { HBox, Image } from '../../../scenery/js/imports.js';
import Tandem from '../../../tandem/js/Tandem.js';
import { combineOptions } from '../../../phet-core/js/optionize.js';
import FELConstants from '../common/FELConstants.js';
import FELKeyboardHelpContent from '../common/view/FELKeyboardHelpContent.js';
import lightBulbOn_png from '../../../scenery-phet/mipmaps/lightBulbOn_png.js';
import battery_png from '../../images/battery_png.js';

export default class TransformerScreen extends Screen<TransformerModel, TransformerScreenView> {

Expand All @@ -27,20 +29,28 @@ export default class TransformerScreen extends Screen<TransformerModel, Transfor
model => new TransformerScreenView( model, tandem.createTandem( 'view' ) ),
combineOptions<ScreenOptions>( {}, FELConstants.SCREEN_OPTIONS, {
name: FaradaysElectromagneticLabStrings.screen.transformerStringProperty,
homeScreenIcon: createHomeScreenIcon(),
homeScreenIcon: createScreenIcon(),
createKeyboardHelpNode: () => new FELKeyboardHelpContent(),
tandem: tandem
}
) );
}
}

//TODO https://github.com/phetsims/faradays-electromagnetic-lab/issues/28 screen icon
function createHomeScreenIcon(): ScreenIcon {
return new ScreenIcon( new Rectangle( 0, 0, 1, 1 ), {
/**
* Creates the icon for this screen.
*/
function createScreenIcon(): ScreenIcon {

const iconNode = new HBox( {
spacing: 5,
children: [ new Image( battery_png ), new Image( lightBulbOn_png ) ]
} );

return new ScreenIcon( iconNode, {
fill: FELColors.screenBackgroundColorProperty,
maxIconWidthProportion: 1,
maxIconHeightProportion: 1
maxIconWidthProportion: 0.85,
maxIconHeightProportion: 0.85
} );
}

Expand Down

0 comments on commit 0a9fc7c

Please sign in to comment.