-
Notifications
You must be signed in to change notification settings - Fork 27
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
Fading out image not working #152
Comments
hey! interpolation is type based in napari-animation, I assume you are setting integers and napari is not coercing them to floats, could you check if this is indeed the root cause? Would ideally be fixed upstream in napari |
Good idea! viewer.camera.angles = (20, -25, 140)
animation.capture_keyframe(steps=60, ease=Easing.QUADRATIC)
img.opacity = 0.0
animation.capture_keyframe(steps=60, ease=Easing.QUADRATIC)
img.opacity = 1.0
animation.capture_keyframe(steps=60, ease=Easing.QUADRATIC) but that did not solve the problem. Just tested again a new script, here I only set the opacity to 0.5, but it completely removes it. from napari_animation import Animation
from napari_animation.easing import Easing
img = viewer.layers[1]
img.opacity =1
viewer.camera.angles = (0, 0, 90)
animation = Animation(viewer)
img.opacity = 1
animation.capture_keyframe(steps=60)
animation.capture_keyframe(steps=120)
img.opacity = 0.5 # <- here, the opacity is set to zero I guess
animation.capture_keyframe(steps=60, ease=Easing.QUADRATIC)
img.opacity = 1.0
animation.capture_keyframe(steps=60, ease=Easing.QUADRATIC) napari_video@2023-03-02@13-59-08.mp4 |
Thanks for spelunking - I'll have to dig properly to figure this out but the reproducible example is a super useful starting point |
I can reproduce this too. It does seem related to #149 |
Ok, here the snippets are the problem actaully. @alisterburt was on the right track with typing issue.
This is then stored in the viewer_state and when interpolation is performed, the wrong interpolation is chosen here because the initial value (a) is an int: napari-animation/napari_animation/interpolation/base_interpolation.py Lines 70 to 88 in 969fefb
So you need to set opacity as a float currently, but this should probably be coerced on the napari side? |
# References and relevant issues At present, despite docstrings stating that gamma and opacity are floats are not enforced by napari. Worse yet, we set the default in a number of places to `1` and not `1.0`. Downstream, vispy does coerce gamma to float so it's not so obvious, but it creeps up if you interrogate the layer state using either `viewer.layers[0].gamma` or `viewer.layers[0]._get_state()` which will return `1` and a type of `int` See: napari/napari-animation#149 Closes: napari/napari-animation#149 Same can happen to opacity, but it's more subtle because of the way the slider value is used. Closes: napari/napari-animation#152 # Description In this PR I set gamma and opacity defaults to `1.0` where they had been previously set to `1` and in the `gamma.setter` and `opacity.setter` I coerce to float so that the user doesn't shoot themselves in the foot accidentally.
In the below example,
should fade out the cell image, but just disappears suddenly.
Afterwards it should fade in again, and works perfectly for the fade in.
Any idea what is causing this fadeout bug? Thanks for reading this issue! :)
napari_video@2023-03-02@12-50-57.mp4
The text was updated successfully, but these errors were encountered: