Skip to content

VisibleColor: support a gradient at the UV/IR transitions #989

Description

@jessegreenberg

From phetsims/photoelectric-effect#230.

In photoelectric-effect, we needed a gradient at the UV/IR transitions from visible color like this:

Image

That is currently not supported by VisibleColor. We solved it like this:

https://github.com/phetsims/totality/blob/7864f4a78e92adab62a2ac7689f0345da2d2c950/photoelectric-effect/js/common/model/PhotoelectricEffectUtils.ts#L151-L166

And see related wavelengthToColorFromStops at that SHA.

Additional discussion:

Details

Marla Schulz  [4:57 PM]
We created a gradient to represent wavelengths beyond the visual spectrum in Photoelectric Effect, and are wondering if this feels like something that might be useful for other sims in the future too. If so we can move it to scenery-phet. Thoughts? phetsims/photoelectric-effect#230. This is the existing utility function for visible wavelengths:
VisibleColor.wavelengthToColor( wavelength )5 repliesSam Reid  [5:20 PM]
Yes, it seems useful and should be added to scenery-phet in my opinion
Chris Malley  [10:04 AM]
Migration of a sim-specific to common (scenery-phet especially) typically occurs when more than one sim needs that feature.  But if you are fairly confident that another sim will need it (the cost is justified) and want to be proactive, I’d say go for it.

FYI, MOTHA also has a wavelength slider whose track includes UV, IR, and visible wavelengths.  In that sim, we chose one color to represent UV and IR, rather than a gradient. (edited) 
Sam Reid  [10:06 AM]
I advised that way because I recalled that it had come up before, but I couldn't back that up with a search. Maybe I was thinking of MOTHA? Not sure
Chris Malley  [10:07 AM]
I don’t know if the MOTHA decision means that MOTHA or Photoelectric Effect are the typical case. Just a data point to use for your decision whether to migrate now.  I would probably open a scenery-phet issue, capture this discussion, and defer doing the work until a 3rd sim needs UV+IR+visible. (edited)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions