Skip to content

Commit

Permalink
Adding 'scale' to CompassNeedleNode options for improved use from Fie…
Browse files Browse the repository at this point in the history
…ldNode, see #113
  • Loading branch information
jonathanolson committed Mar 26, 2024
1 parent 7119990 commit 96eaef9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions js/common/view/CompassNeedleNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
import faradaysElectromagneticLab from '../../faradaysElectromagneticLab.js';
import { Shape } from '../../../../kite/js/imports.js';
import FELColors from '../FELColors.js';
import { Node, Path, TColor } from '../../../../scenery/js/imports.js';
import { Node, NodeOptions, Path, TColor } from '../../../../scenery/js/imports.js';
import optionize from '../../../../phet-core/js/optionize.js';
import PickOptional from '../../../../phet-core/js/types/PickOptional.js';

const NEEDLE_ASPECT_RATIO = 25 / 7; // length:waist

Expand All @@ -26,13 +27,13 @@ type SelfOptions = {
southFill?: TColor;
};

type CompassNeedleNodeOptions = SelfOptions;
type CompassNeedleNodeOptions = SelfOptions & PickOptional<NodeOptions, 'scale'>;

export default class CompassNeedleNode extends Node {

public constructor( providedOptions?: CompassNeedleNodeOptions ) {

const options = optionize<CompassNeedleNodeOptions, SelfOptions>()( {
const options = optionize<CompassNeedleNodeOptions, SelfOptions, NodeOptions>()( {

// SelfOptions
length: 25,
Expand Down Expand Up @@ -65,9 +66,9 @@ export default class CompassNeedleNode extends Node {
lineWidth: 0.5
} );

super( {
children: [ southPath, northPath, unionPath ]
} );
options.children = [ southPath, northPath, unionPath ];

super( options );
}
}

Expand Down
8 changes: 4 additions & 4 deletions js/common/view/FieldNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ export default class FieldNode extends Sprites {
// Convert a CompassNeedleNode to a Sprite.
const compassNeedleNode = new CompassNeedleNode( {
northFill: compassNeedleNorthColor,
southFill: compassNeedleSouthColor
} );
southFill: compassNeedleSouthColor,

// Apply a scale to increase resolution (we'll apply the inverse scale when rendering).
compassNeedleNode.scale( COMPASS_NEEDLE_RESOLUTION_MULTIPLIER );
// Apply a scale to increase resolution (we'll apply the inverse scale when rendering).
scale: COMPASS_NEEDLE_RESOLUTION_MULTIPLIER
} );

let spriteImage!: SpriteImage;

Expand Down

0 comments on commit 96eaef9

Please sign in to comment.