Skip to content

Commit

Permalink
add minor ticks in a loop, see #54
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Jan 9, 2025
1 parent a47b0bc commit 0135cac
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions js/bloch-sphere/view/MeasurementTimerControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type MeasurementTimerControlOptions = SelfOptions & WithRequired<PanelOpt

// constants
const SLIDER_TRACK_SIZE = new Dimension2( 150, 0.1 );
const NUMBER_OF_MINOR_TICKS = 7;

export default class MeasurementTimerControl extends Node {

Expand All @@ -49,17 +50,20 @@ export default class MeasurementTimerControl extends Node {
thumbCenterLineStroke: null,
trackSize: SLIDER_TRACK_SIZE,
trackFillEnabled: Color.BLACK,
constrainValue: value => Utils.roundToInterval( value, 0.2 ),
constrainValue: value => Utils.roundToInterval(
value,
timeToMeasurementProperty.rangeProperty.value.max / ( NUMBER_OF_MINOR_TICKS + 1 )
),
orientation: Orientation.HORIZONTAL,
majorTickLength: 10,
minorTickLength: 5
} );
timeToMeasurementSlider.addMajorTick( 0, new Text( '0', { font: new PhetFont( 15 ) } ) );
timeToMeasurementSlider.addMajorTick( maxMeasurementTime, new Text( 't', { font: new PhetFont( 15 ) } ) );
timeToMeasurementSlider.addMinorTick( 0.2 * maxMeasurementTime );
timeToMeasurementSlider.addMinorTick( 0.4 * maxMeasurementTime );
timeToMeasurementSlider.addMinorTick( 0.6 * maxMeasurementTime );
timeToMeasurementSlider.addMinorTick( 0.8 * maxMeasurementTime );
_.times( NUMBER_OF_MINOR_TICKS, i => {
const fraction = ( i + 1 ) / ( NUMBER_OF_MINOR_TICKS + 1 );
timeToMeasurementSlider.addMinorTick( fraction * maxMeasurementTime );
} );

const timeIndicatorScale = 15;
const timeIndicator = new ArrowNode( 0, timeIndicatorScale, 0, 0, {
Expand Down

0 comments on commit 0135cac

Please sign in to comment.