Skip to content

Commit

Permalink
Adding detail to the getColor function of pixel representation, see #39
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinVallejo committed Oct 3, 2024
1 parent 1ac74d2 commit 5f5647c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions js/coins/view/CoinSetPixelRepresentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export default class CoinSetPixelRepresentation extends CanvasNode {
let getColor: ( value: number ) => string;
switch( this.experimentStateProperty.value ) {
case 'preparingToBeMeasured':
// Coins are flipping, so alternate between grey and light grey. 0 is used when repreparing.
getColor = ( value: number ) => {
return value === 1 ? 'grey' :
value === 0.5 ? '#aaa' : // light grey
Expand All @@ -146,16 +147,25 @@ export default class CoinSetPixelRepresentation extends CanvasNode {
};
break;
case 'readyToBeMeasured':
// Quantum case for coins traveling to the box
getColor = ( value: number ) => {
return value === 1 ? 'grey' : 'transparent';
};
break;
case 'measuredAndHidden':
getColor = ( value: number ) => {
return value === 1 ? 'grey' : 'transparent';
};
if ( this.coinSetInTestBoxProperty.value ) {
// The coins are already in the box, just show them as grey.
getColor = () => 'grey';
}
else {
// Classical case for coins traveling to the box
getColor = ( value: number ) => {
return value === 1 ? 'grey' : 'transparent';
};
}
break;
default:
assert && assert( false, 'Not all states are being considered in CoinSetPixelRepresentation' );
getColor = () => {
return 'red';
};
Expand Down

0 comments on commit 5f5647c

Please sign in to comment.