Closed pixelzoom closed 3 years ago
I also thought it was appropriate to ask @pixelzoom to review phetsims/chipper#1061
Done.
To review: ...
I'll put my review notes in this comment, and add to them as I go. Don't do anything with these until I assign back to @samreid, because I'll be modifying this comment.
SCENERY/colorProfileProperty.js
[x] 'default' is duplicated in colorProfileProperty.js 2x, initialize-globals.js 1x, ProfileColorProperty (as this.colorProfileMap.default
) and in numerous instantiations of ProfileColorProperty. Can we factor out (some? all?) of this duplication? See note about SceneryConstants.PROJECTOR_COLOR_PROFILE_NAME below, it's the same problem.
[ ] Re "// TODO: Should we move global.view.colorProfile.profileNameProperty to global.view.colorProfileProperty"... Ask designers. Personally, I'd like to see colorProfileProperty
and all instrumented instances of ProfileColorProperty under global.view.colors
. That will require a new tandem like Tandem.GLOBAL_COLORS. UPDATE by @samreid: moved to https://github.com/phetsims/scenery/issues/1251#issuecomment-887720351
SCENERY/ProfileColorProperty.js
// @protected - used elsewhere in this file but outside of this class.
// values are mutated by the color wrapper.
this.colorProfileMap = colorProfileMap;
[x] Add a comment about what's going on here:
49 this.link( color => {
[x] Add more doc here, identify the specific iframe(s), etc.
// receives iframe communication to set a color
window.addEventListener( 'message', event => {
A couple of sims that use these new patterns, such as GasPropertiesColorProfile.
[ ] As we were discusing in https://github.com/phetsims/scenery-phet/issues/515#issuecomment-882628081... I think we should shed the "ColorProfile" baggage, choose another name, and make it the PhET convention. +1 for (e.g) GasPropertiesColors.js. UPDATE from @samreid: This will be addressed in https://github.com/phetsims/scenery-phet/issues/686
[ ] Perhaps a PSA to developers about the pitfalls of defining ProfileColorProperty instances where they are used? @samreid was originally advocating for this, and in https://github.com/phetsims/scenery-phet/issues/515#issuecomment-882619310 @zepumph seems to think that's still desirable. Grouping ProfileColorProperty instances in one place has a lot of advantages, and that's the pattern that I'd like to use. It might be easier for designers if all devs used the same pattern. UPDATE by @samreid: this will be covered in https://github.com/phetsims/scenery/issues/1257#issue-954154030
[ ] Change the CRC item for "ColorProfile" to something relevant to this new pattern. UPDATE by @samreid: also moved to https://github.com/phetsims/scenery/issues/1257
Changes to ProjectorModeCheckbox.js
[x] We have SceneryConstants.PROJECTOR_COLOR_PROFILE_NAME, but have duplicated 'projector' string lteral in instantions of ProfileColorProperty. Similar problem to the duplication of 'default' noted for colorProfileProperty.js.
[x] If you started the sim with the colorProfile
query parameter specifying something other than "projector", then line 59 (shown below) is buggy. If sim started with something other than "projector", then you need to save/restore that profile when switching off projector mode.
59 ( isProjectorMode ? SceneryConstants.PROJECTOR_COLOR_PROFILE_NAME : phet.chipper.colorProfiles[ 0 ] );
Otherwise ProjectorModeCheckbox.js seems OK for now. I think we'll eventually want to get rid of this control, and have a more general way of selecting color profile from the Preferences dialog.
Any related files you think are relevant.
package.json - I have reservations about the ordered list in phet.colorProfiles
, the fact that it defaults to [ 'default' ]
, the fact that the sim starts up with phet.colorProfiles[0]
, etc. There's some non-obvious stuff here. But we'll see how it goes.
Review completed, comments in https://github.com/phetsims/scenery-phet/issues/515#issuecomment-882927243. Back to @samreid.
'default' is duplicated in colorProfileProperty.js 2x, initialize-globals.js 1x, ProfileColorProperty (as this.colorProfileMap.default) and in numerous instantiations of ProfileColorProperty
Would you like to use computed property names? It could factor out those terms like so: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer
screenBackgroundColorProperty: new ProfileColorProperty( 'screenBackgroundColor', {
[ SceneryConstants.DEFAULT_COLOR_PROFILE_NAME ]: 'black',
[ SceneryConstants.PROJECTOR_COLOR_PROFILE_NAME ]: 'white'
} ),
We have never tried to factor out key names before, I wonder what would happen if we did that across our project.
Would you like to use computed property names?
No, definitely not. I hadn't considered that.
... I think we should shed the "ColorProfile" baggage, choose another name, and make it the PhET convention. +1 for (e.g) GasPropertiesColors.js.
In the above commits, I renamed this .js file for my sims. For example, GasPropertiesColorProfile.js is now GasPropertiesColors.js
In the above commit, the .js file naming convention was applied to simula-rasa.
perennial/data/color-profiles
. Won't all sims have a color profile now?Thanks, I removed color-profiles.
Removing color-profiles has broken phetmarks for all release branches. I'm trying to test patches and RCs for ph-scale and natural-selection, and phetmarks crashes with:
jquery-2.1.0.min.js:4 GET http://localhost/~cmalley/GitHub/perennial/data/color-profiles 404 (Not Found)
It's super inconvenient not to have a working phetmarks for release branches.
On Slack dev-public, @zepumph proposed that someone should "MR phetmarks once and for all to be graceful if any data lists don't exist." That sounds like a great idea, but I don't have time to do that. So I am going to restore color-profiles.
Something seemed a little funky when I reverted the deletion of color-profiles. @samreid please check my work.
Maybe a more robust way around this problem will be for phetmarks to depend on annual instead of perennial.
The revert commit looks good, thanks!
Since this issue is getting long, here is a link to the remaining work: https://github.com/phetsims/scenery-phet/issues/515#issuecomment-882927243
Thanks for the review recommendations, I addressed them in the commits. I also changed PROJECTOR_COLOR_PROFILE_NAME
to PROJECTOR_COLOR_PROFILE
. Every issue has been addressed or moved to a side issue. Back to @pixelzoom to see if there is any remaining work for this issue.
I had to expand this issue multiple times to find my review comments. If I need to get to them again, direct link is https://github.com/phetsims/scenery-phet/issues/515#issuecomment-882927243
@samreid Sorry, I don't have time to look through each commit to see how you addressed the review comments. If you want to summarize and point me to relevant commit(s), I'll be happy to take a look at specific things.
I did notice that the CRC item is now:
All sims should use a color file named MyRepoColorProfile.js or, if using abbreviations, MRColorProfile.js, and use ProfileColorProperty where appropriate, even if they have a single (default) profile. ...
I don't agree with the naming convention. I'd like to shed the "ColorProfile" baggage, and call this file MyRepoColors.js. And I intend to put both ColorDef
and ProfileColorProperty
instances in this file.
Sorry, I don't have time to look through each commit to see how you addressed the review comments.
The changes were straightforward and the re-review step can be skipped at your discretion.
If you want to summarize and point me to relevant commit(s), I'll be happy to take a look at specific things.
There are 9 commits listed above with these commit messages:
The changes were straightforward and I didn't need specific feedback on any of them, just reassigned to you to double-check as part of review protocol.
I don't agree with the naming convention. I'd like to shed the "ColorProfile" baggage, and call this file MyRepoColors.js.
As mentioned in an UPDATE in https://github.com/phetsims/scenery-phet/issues/515#issuecomment-882927243, this will be addressed in https://github.com/phetsims/scenery-phet/issues/686
I did a quick skim of the commits. Looks like good work, and I didn't see anything amiss.
Back to @samreid in case there's anything else to do here.
The current CRC checklist item no longer makes sense, I believe we no longer want the colors file to look like "*ColorProfile.js", reopening.
@samreid, does this feel adequate to you?
Since I suggested changing the CRC item, and @samreid is on vacation, I took a look. The changes look great to me.
Since this was reopened for the CRC item, I'll go ahead an re-close.
I discovered while adding tandems to Gas Properties in https://github.com/phetsims/gas-properties/issues/30 that
ColorProfile
is not set up for PhET-iO use. I'm not sure how important it is, that would be a question for designers. But I can imagine clients wanting to (for example) customize the color of particles in Gas Properties.