-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SpectrumNode can be undersized for non-integer dimensions #500
Comments
I'd think that you'd want to use It also would be good to reimplement |
Okay. Assigning to @arnabp to add |
In Slack, @jbphet said:
SpectrumNode work completed in #501. Pull scenery-phet to test in blackbody-spectrum. The first thing I notice (comparing to blackbody-spectrum 1.0.0-dev.16) is that brightness looks reduced. I'm not sure why that is, because the algorithm to compute the colors is unchanged. I have not added Math.ceil calls yet, because there’s no indication in CanvasNode docs that integer values are required. Let me know if the original problem ("graph ended up being narrower than expected") is still present. |
Thanks @arnabp, I'll have a look. Is the "graph ended up being narrower than expected" problem still present? |
No idea why the results are different when rendering to I see that I'm also not sure how to proceed with this issue. I've currently documented // {Dimension2} desired size of the Node. Actual size will be set to integer values via Math.ceil
size: DEFAULT_SIZE, But it seems problematic to ask for a specific size, then get something else. Perhaps we should do something like render the spectrum to a canvas that is sized a bit larger, then scale the |
I said:
That's exactly what I did in the above commit. I think this is the way to go. But @jbphet @arnabp let me know what you think. A general concern with this issue is that some sim may be unknowingly relying on |
Testing in blackbody shows no issues, the spectrum is back to being smooth and the SpectrumNode handles the original graph width problem just fine, so everything looks good on this end. |
Assigning this back to you @pixelzoom, not sure if you want to keep it alive to try to port to CanvasNode again in the future and try to resolve the strange rendering issue, or leave it as is. |
I think I'll just punt on using CanvasNode here. Closing. |
Reopening because this is affecting phetsims/wave-interference#402. |
Confirmed that phetsims/wave-interference#402 is not a problem in master, closing again. |
In phetsims/blackbody-spectrum#62 we ran into an issue where the spectrum representation for visible light on the graph ended up being narrower than expected, and that smallness got worse as the node was scaled up (to see a screen capture of how this looked, search the issue for the word "rainbow"). After much investigation by @arnabp and a little by myself, we traced the problem to
SpectrumNode
, specifically the following code:In our particular case, the value of
config.size.width
was 54.999999.... due to floating point issues, and the canvas was flooring that value to 54, so the last row of pixels was essentially missing. When scaled up, that gap become very apparent. When we changed to code to:...the problem went away. However, we don't know enough about the nature and usages of this node to feel comfortable making changes like this, so we ended up doing the rounding in the blackbody-spectrum code in order to resolve the immediate problem. Our question is whether this should be changed in
SpectrumNode
. It seems like perhapsMath.ceil()
would be even better, since it would never cut things off, but again, I'm not sure what the potential side effects might be with a change of this nature.Assigning to @pixelzoom to get his input since he is listed as the first author in the comments.
The text was updated successfully, but these errors were encountered: