Skip to content

Commit

Permalink
Adding MULTI_COIN_ANIMATION_QUANTITIES, see #39
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinVallejo committed Oct 3, 2024
1 parent 7c84cdb commit 8a0e52b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 3 additions & 0 deletions js/coins/model/CoinsExperimentSceneModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ type MeasuredCoinStates = ClassicalCoinStates | QuantumCoinStates;
// allowed values for the number of coins to use in the multi-coin experiment
export const MULTI_COIN_EXPERIMENT_QUANTITIES = [ 10, 100, 10000 ];

// Excluding the 10000 as they are represented as pixels
export const MULTI_COIN_ANIMATION_QUANTITIES = MULTI_COIN_EXPERIMENT_QUANTITIES.filter( quantity => quantity !== 10000 );

// max coins used in any of the experiments
export const MAX_COINS = Math.max( ...MULTI_COIN_EXPERIMENT_QUANTITIES );

Expand Down
10 changes: 4 additions & 6 deletions js/coins/view/MultiCoinTestBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Color, HBox, HBoxOptions, LinearGradient, Node, Rectangle } from '../..
import isSettingPhetioStateProperty from '../../../../tandem/js/isSettingPhetioStateProperty.js';
import TwoStateSystemSet from '../../common/model/TwoStateSystemSet.js';
import quantumMeasurement from '../../quantumMeasurement.js';
import { MULTI_COIN_EXPERIMENT_QUANTITIES } from '../model/CoinsExperimentSceneModel.js';
import { MULTI_COIN_ANIMATION_QUANTITIES } from '../model/CoinsExperimentSceneModel.js';
import { ExperimentMeasurementState } from '../model/ExperimentMeasurementState.js';
import SmallCoinNode, { SmallCoinDisplayMode } from './SmallCoinNode.js';

Expand Down Expand Up @@ -185,17 +185,15 @@ export default class MultiCoinTestBox extends HBox {
*/
public static getRadiusFromCoinQuantity( coinQuantity: number ): number {
assert && assert(
MULTI_COIN_EXPERIMENT_QUANTITIES.includes( coinQuantity ), 'unsupported number of coins' );
MULTI_COIN_ANIMATION_QUANTITIES.includes( coinQuantity ), 'unsupported number of coins' );
let radius;
if ( coinQuantity === 10 ) {
radius = 12;
}
else if ( coinQuantity === 100 ) {
radius = 6;
}
else {
radius = 2;
radius = 6;
}

return radius;
}
}
Expand Down
5 changes: 2 additions & 3 deletions js/coins/view/MultipleCoinAnimations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Animation from '../../../../twixt/js/Animation.js';
import Easing from '../../../../twixt/js/Easing.js';
import { MEASUREMENT_PREPARATION_TIME } from '../../common/model/TwoStateSystemSet.js';
import quantumMeasurement from '../../quantumMeasurement.js';
import CoinsExperimentSceneModel, { MULTI_COIN_EXPERIMENT_QUANTITIES } from '../model/CoinsExperimentSceneModel.js';
import CoinsExperimentSceneModel, { MULTI_COIN_ANIMATION_QUANTITIES } from '../model/CoinsExperimentSceneModel.js';
import CoinExperimentMeasurementArea from './CoinExperimentMeasurementArea.js';
import CoinsExperimentSceneView from './CoinsExperimentSceneView.js';
import MultiCoinTestBox from './MultiCoinTestBox.js';
Expand All @@ -40,8 +40,7 @@ public readonly startIngressAnimationForCoinSet: ( forReprepare: boolean ) => vo
const movingCoinNodes = new Map<number, SmallCoinNode[]>();

// The 10000 coins case will be animated separately
const ANIMATION_QUANTITIES = MULTI_COIN_EXPERIMENT_QUANTITIES.filter( quantity => quantity !== 10000 );
ANIMATION_QUANTITIES.forEach( quantity => {
MULTI_COIN_ANIMATION_QUANTITIES.forEach( quantity => {
const radius = MultiCoinTestBox.getRadiusFromCoinQuantity( quantity );
const coinNodes: SmallCoinNode[] = [];
_.times( quantity, () => {
Expand Down

0 comments on commit 8a0e52b

Please sign in to comment.