Skip to content

Commit

Permalink
improve the gradient used to make state vector look more 3D, see #54
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Jan 4, 2025
1 parent 39514b2 commit 08d8c5d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/common/view/BlochSphereNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Visual representation of the Bloch Sphere, meaning an orb with axis and the state vector.
*
* @author Agustín Vallejo
* @author John Blanco (PhET Interactive Simulations)
*/

import BooleanProperty from '../../../../axon/js/BooleanProperty.js';
Expand Down Expand Up @@ -238,13 +239,13 @@ export default class BlochSphereNode extends Node {
Math.cos( polarAngle )
);
const distanceFromMiddleBack = tipPositionCartesian.distanceXYZ( -1, 0, 0 );
const stateVectorTipOpacity = distanceFromMiddleBack / 2;
const stateVectorTipOpacity = Math.pow( distanceFromMiddleBack / 2, 2 );
const stateVectorGradient = new LinearGradient(
stateVector.tailX,
stateVector.tailY,
stateVector.tipX,
stateVector.tipY
).addColorStop( 0, 'rgba(0,0,0,0.5)' ).addColorStop( 1, `rgba(0,0,0,${stateVectorTipOpacity})` );
).addColorStop( 0, 'rgba(0,0,0,0.4)' ).addColorStop( 1, `rgba(0,0,0,${stateVectorTipOpacity})` );
stateVector.fill = stateVectorGradient;
stateVector.stroke = stateVectorGradient;

Expand Down

0 comments on commit 08d8c5d

Please sign in to comment.