Skip to content

Commit

Permalink
Updates to logic of area gradient color, see #38
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinVallejo committed May 23, 2023
1 parent fddc555 commit a269e1c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
7 changes: 6 additions & 1 deletion js/KeplersLawsConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import keplersLaws from './keplersLaws.js';
import PhetFont from '../../scenery-phet/js/PhetFont.js';
import SolarSystemCommonColors from '../../solar-system-common/js/SolarSystemCommonColors.js';
import { Color } from '../../scenery/js/imports.js';

const KeplersLawsConstants = {
PANELS_MIN_WIDTH: 250,
Expand All @@ -18,7 +20,10 @@ const KeplersLawsConstants = {
TIMER_READOUT_OPTIONS: {
font: new PhetFont( { size: 18 } ),
fill: 'black'
}
},

AREA_COLOR: SolarSystemCommonColors.orbitColorProperty,
DISTANCE_LABEL_COLOR: new Color( '#ccb285' )
};

keplersLaws.register( 'KeplersLawsConstants', KeplersLawsConstants );
Expand Down
23 changes: 13 additions & 10 deletions js/keplers-laws/view/EllipticalOrbitNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ export default class EllipticalOrbitNode extends Path {
)
}, SolarSystemCommonConstants.TEXT_OPTIONS, {
scale: 1.5,
stroke: '#ccb285',
fill: '#ccb285'
stroke: KeplersLawsConstants.DISTANCE_LABEL_COLOR,
fill: KeplersLawsConstants.DISTANCE_LABEL_COLOR
} ) );
const stringLabelNode2 = new RichText( 'd<sub>2', combineOptions<TextOptions>(
{
Expand All @@ -122,8 +122,8 @@ export default class EllipticalOrbitNode extends Path {
)
}, SolarSystemCommonConstants.TEXT_OPTIONS, {
scale: 1.5,
stroke: '#ccb285',
fill: '#ccb285'
stroke: KeplersLawsConstants.DISTANCE_LABEL_COLOR,
fill: KeplersLawsConstants.DISTANCE_LABEL_COLOR
} ) );
const radiusLabelNode = new RichText( 'r', combineOptions<TextOptions>( {
visibleProperty: new DerivedProperty(
Expand All @@ -137,8 +137,8 @@ export default class EllipticalOrbitNode extends Path {
)
}, SolarSystemCommonConstants.TEXT_OPTIONS, {
scale: 1.5,
stroke: '#ccb285',
fill: '#ccb285'
stroke: KeplersLawsConstants.DISTANCE_LABEL_COLOR,
fill: KeplersLawsConstants.DISTANCE_LABEL_COLOR
} ) );

// FIRST LAW: Axis, foci, and Ellipse definition lines
Expand All @@ -160,14 +160,14 @@ export default class EllipticalOrbitNode extends Path {
visibleProperty: model.eccentricityVisibleProperty
} );
const stringsPath = new Path( null, {
stroke: '#ccb285',
stroke: KeplersLawsConstants.DISTANCE_LABEL_COLOR,
lineWidth: 3,
visibleProperty: model.stringsVisibleProperty,
lineDash: [ 10, 2 ]
} );
const fociOptions = {
fill: '#29ABE2',
stroke: SolarSystemCommonColors.backgroundProperty,
stroke: 'black',
scale: 0.8,
center: Vector2.ZERO,
visibleProperty: model.fociVisibleProperty
Expand Down Expand Up @@ -216,7 +216,7 @@ export default class EllipticalOrbitNode extends Path {
visible: false
} ) );
areaPaths.push( new Path( null, {
fill: SolarSystemCommonColors.orbitColorProperty
fill: KeplersLawsConstants.AREA_COLOR
} ) );
const areaValueProperty = new NumberProperty( 0 );
areaValueProperties.push( areaValueProperty );
Expand Down Expand Up @@ -410,7 +410,10 @@ export default class EllipticalOrbitNode extends Path {

// Activate area path
// Opacity lowered down to 0.8 for stylistic purposes
areaPaths[ i ].opacity = area.alreadyEntered ? area.insideProperty.value ? 1 : 0.7 * area.completion + 0.1 : 0;
const opacity = area.alreadyEntered ? area.insideProperty.value ? 1 : 0.7 * area.completion + 0.1 : 0;
// const fillBrightness = area.alreadyEntered ? area.insideProperty.value ? 1 : area.completion : 0; // TODO: Take a design decision
areaPaths[ i ].opacity = opacity;
// areaPaths[ i ].fill = KeplersLawsConstants.AREA_COLOR.value.colorUtilsBrightness( Utils.linear( 0, 1, -0.6, 0.6, fillBrightness ) );
areaPaths[ i ].shape = new Shape().moveTo( radiusC, 0 ).ellipticalArc(
0, 0, radiusX, radiusY, 0, startAngle, endAngle, false
).close();
Expand Down

1 comment on commit a269e1c

@AgustinVallejo
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its actually #37

Please sign in to comment.