Skip to content

Commit

Permalink
add CoilOptions.electronsVisible for use by screen icons, #28
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Feb 29, 2024
1 parent c22fa71 commit 20556c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 5 additions & 1 deletion js/common/model/Coil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ type SelfOptions = {
// Horizontal spacing between loops in the coil. Zero is tightly packed.
loopSpacing?: number;

// Initial value of electronsVisibleProperty.
electronsVisible?: boolean;

// Initial value of electronSpeedScaleProperty, a developer control.
electronSpeedScale?: number;
};
Expand Down Expand Up @@ -124,6 +127,7 @@ export default class Coil extends PhetioObject {
wireWidth: 16,
loopSpacing: 8,
electronSpeedScale: 1,
electronsVisible: true,

// PhetioObjectOptions
phetioState: false
Expand Down Expand Up @@ -173,7 +177,7 @@ export default class Coil extends PhetioObject {
this.loopRadiusProperty = new DerivedProperty( [ this.loopAreaProperty ],
loopArea => Math.sqrt( loopArea / Math.PI ) );

this.electronsVisibleProperty = new BooleanProperty( true, {
this.electronsVisibleProperty = new BooleanProperty( options.electronsVisible, {
tandem: options.tandem.createTandem( 'electronsVisibleProperty' ),
phetioFeatured: true
} );
Expand Down
7 changes: 2 additions & 5 deletions js/common/view/FELScreenIconFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,14 @@ const FELScreenIconFactory = {
*/
function createCoilNode( numberOfLoops: number, loopSpacing: number ): Node {

const currentAmplitudeProperty = new NumberProperty( 0 );
const currentAmplitudeRange = FELConstants.CURRENT_AMPLITUDE_RANGE;

const coil = new Coil( currentAmplitudeProperty, currentAmplitudeRange, {
const coil = new Coil( new NumberProperty( 0 ), FELConstants.CURRENT_AMPLITUDE_RANGE, {
numberOfLoopsRange: new RangeWithValue( numberOfLoops, numberOfLoops, numberOfLoops ),
loopSpacing: loopSpacing,
maxLoopArea: 7000,
loopAreaPercentRange: new RangeWithValue( 100, 100, 100 ),
electronsVisible: false,
tandem: Tandem.OPT_OUT
} );
coil.electronsVisibleProperty.value = false;

// We must have a subclass of FELMovable associated with a coil's background layer. This one will do.
const movable = new BarMagnet( { tandem: Tandem.OPT_OUT } );
Expand Down

0 comments on commit 20556c2

Please sign in to comment.