Skip to content

Commit

Permalink
Using Node.rasterized() for toolbox ruler and timer images. #253
Browse files Browse the repository at this point in the history
  • Loading branch information
Denz1994 committed May 15, 2018
1 parent c91bc0b commit 57e0ab4
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions js/common/view/ToolboxPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ define( function( require ) {
// modules
var BooleanProperty = require( 'AXON/BooleanProperty' );
var HBox = require( 'SCENERY/nodes/HBox' );
var Image = require( 'SCENERY/nodes/Image' );
var inherit = require( 'PHET_CORE/inherit' );
var massesAndSprings = require( 'MASSES_AND_SPRINGS/massesAndSprings' );
var MassesAndSpringsConstants = require( 'MASSES_AND_SPRINGS/common/MassesAndSpringsConstants' );
Expand Down Expand Up @@ -61,6 +60,7 @@ define( function( require ) {
tandem: tandem.createTandem( 'isRunningProperty' )
} );
var timer = new TimerNode( secondsProperty, isRunningProperty );
timer.scale( 0.4 );

// Create ruler to be turned into icon
var rulerWidth = 397; // 1 meter
Expand All @@ -78,20 +78,16 @@ define( function( require ) {
'',
{ tandem: tandem.createTandem( 'ruler' ) } );
ruler.rotate( 40, false );

// {Image} Create timer icon. Visible option is used only for reset() in ToolboxPanel.js
var rulerIcon;
ruler.toDataURL( function( image ) {

rulerIcon = new Image( image, {
// Instead of changing the rendering, we'll dynamically generate a mipmap so that the ruler icon appearance looks better.
// See https://github.com/phetsims/masses-and-springs/issues/199.
mipmap: true,
cursor: 'pointer',
pickable: true,
scale: 0.1,
tandem: tandem.createTandem( 'rulerIcon' )
} );
ruler.scale( 0.1 );

// {Node} Create timer icon. Visible option is used only for reset() in ToolboxPanel.js
var rulerIcon = ruler.rasterized( {
// Instead of changing the rendering, we'll dynamically generate a mipmap so that the ruler icon appearance looks better.
// See https://github.com/phetsims/masses-and-springs/issues/199.
mipmap: true,
cursor: 'pointer',
resolution: 5,
tandem: tandem.createTandem( 'rulerIcon' )
} );

// Drag listener for event forwarding: rulerIcon ---> rulerNode
Expand Down Expand Up @@ -119,17 +115,11 @@ define( function( require ) {
rulerIcon.visible = !visible;
} );

// {Image} Create timer icon. Visible option is used only for reset() in ToolboxPanel.js
var timerIcon;
timer.toDataURL( function( image ) {

timerIcon = new Image( image, {
cursor: 'pointer',
pickable: true,
scale: 0.4,
tandem: tandem.createTandem( 'timerIcon' )
} );

// {Node} Create timer icon. Visible option is used only for reset() in ToolboxPanel.js
var timerIcon = timer.rasterized( {
cursor: 'pointer',
resolution: 5,
tandem: tandem.createTandem( 'timerIcon' )
} );

// Drag listener for event forwarding: timerIcon ---> timerNode
Expand Down

0 comments on commit 57e0ab4

Please sign in to comment.