Skip to content

Commit

Permalink
Add gradients, see: #27
Browse files Browse the repository at this point in the history
  • Loading branch information
marlitas committed Jun 21, 2022
1 parent ab502bc commit 5b9af5c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions js/intro/view/PipeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Vector2 from '../../../../dot/js/Vector2.js';
import ModelViewTransform2 from '../../../../phetcommon/js/view/ModelViewTransform2.js';
import optionize from '../../../../phet-core/js/optionize.js';
import EmptyObjectType from '../../../../phet-core/js/types/EmptyObjectType.js';
import { FireListener, Node, LinearGradient, NodeOptions, Path, Rectangle } from '../../../../scenery/js/imports.js';
import { FireListener, Node, LinearGradient, NodeOptions, Path, Rectangle, RadialGradient } from '../../../../scenery/js/imports.js';
import meanShareAndBalance from '../../meanShareAndBalance.js';
import PipeModel from '../model/PipeModel.js';
import MeanShareAndBalanceConstants from '../../common/MeanShareAndBalanceConstants.js';
Expand Down Expand Up @@ -78,16 +78,19 @@ export default class PipeNode extends Node {


// Valve drawing
const valveGradient = new RadialGradient( 0, 0, 0, 0, 0, VALVE_RADIUS + 2 ).addColorStop( 0, 'white' ).addColorStop( 1, 'grey' );
this.innerValve = new Path( createInnerCircle( VALVE_RADIUS, PIPE_WIDTH ),
{ fill: 'black' } );
this.outerValve = new Path( createOuterCircle( VALVE_RADIUS ), { fill: 'gray' } );
this.outerValve = new Path( createOuterCircle( VALVE_RADIUS ), { fill: valveGradient } );

// Inner pipe shows water color when pipe is opened.
this.innerPipe = new Rectangle( 0, 0, PIPE_WIDTH, VALVE_RADIUS * 2, {
fill: null,
center: this.innerValve.center
} );

const handleGripGradient = new LinearGradient( -2, -2, 8, 0 ).addColorStop( 0, 'red' ).addColorStop( 0.4, 'firebrick' );

this.handleBase = new Rectangle( 0, 0, HANDLE_WIDTH, 3, {
fill: pipeGradient,
stroke: 'black',
Expand All @@ -103,7 +106,7 @@ export default class PipeNode extends Node {
.close();

this.handleGrip = new Path( handleShape, {
fill: 'red',
fill: handleGripGradient,
stroke: 'black',
y: this.handleBase.top + 1
} );
Expand Down

0 comments on commit 5b9af5c

Please sign in to comment.