phetsims / wave-interference

"Wave Interference" is an educational simulation in HTML5, by PhET Interactive Simulations.
MIT License
19 stars 5 forks source link

Pixel polishing for the wavelength slider #396

Closed samreid closed 5 years ago

samreid commented 5 years ago

https://github.com/phetsims/wave-interference/issues/377 said:

Wavelength panel

However, some of this work is blocked by #394, so I've split it into this new issue.

samreid commented 5 years ago

After changes in #394, I added this code

      model.onProperty.linkAttribute( incidentBeam, 'visible' );
      model.onProperty.linkAttribute( transmittedBeam, 'visible' );

      const wavelengthToColor = VisibleColor.wavelengthToColor;
      const wavelengthPanel = new WaveInterferencePanel(
        new NumberControl( wavelengthString, model.wavelengthProperty, new Range( 380, 780 ), {
          titleNodeOptions: {
            font: WaveInterferenceConstants.DEFAULT_FONT
          },
          numberDisplayOptions: {
            font: new PhetFont( 14 ),
            valuePattern: '{0} nm'
          },
          sliderOptions: {
            trackNode: new SpectrumTrack( model.wavelengthProperty, {
              minValue: 380,
              maxValue: 780,
              valueToColor: wavelengthToColor,
              size: new Dimension2( 160, 20 )
            } ),
            thumbNode: new SpectrumThumb( model.wavelengthProperty, {
              valueToColor: wavelengthToColor,
              width: 25,
              height: 25,
              cursorHeight: 20
            } )
          },
          layoutFunction: NumberControl.createLayoutFunction3( {
            // alignTitle: 'left'
          } )
        } ), _.extend( PANEL_OPTIONS, {
          left: laserPointerNode.left,
          top: apertureScaleIndicatorNode.top,
          xMargin: 6
        } ) );

and now it looks like this:

image

I am hesitant to commit this until the API is finalized in scenery-phet, but I wanted to check that the pixel polishing is as-desired (from the screenshot). @arouinfar can you please comment?

arouinfar commented 5 years ago

@samreid the layout is looking great! I would suggest that the tweakers are made a bit smaller so their height matches the height of the wavelength readout.

image

samreid commented 5 years ago

I finished the prescribed updates, @arouinfar can you please review on phettest/master?

arouinfar commented 5 years ago

Look great! Thanks @samreid.