-
Notifications
You must be signed in to change notification settings - Fork 75
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
Add button to automatically apply RGB presets #2558
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2558 +/- ##
==========================================
- Coverage 90.83% 90.79% -0.04%
==========================================
Files 160 160
Lines 19291 19354 +63
==========================================
+ Hits 17523 17573 +50
- Misses 1768 1781 +13 ☔ View full report in Codecov by Sentry. |
I'll add a test tomorrow, FWIW. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work quite well and gives us a good starting place to test against a bunch of different scenarios and tweak the underlying algorithm/defaults. I'm a bit torn about whether this is too slow that we should set the underlying glue state directly or so fast that we should intentionally slow it down so the user can see the steps being applied 😂 so I guess that means we should just leave it as-is, at least for now.
This could definitely use test coverage before merge as well, though!
7e820eb
to
0a0a813
Compare
This comment was marked as resolved.
This comment was marked as resolved.
0a0a813
to
9120753
Compare
OK looks like expected now, I think. |
if n_visible > 2: | ||
default_opacity = 1 / math.log2(n_visible) | ||
# Sample along a colormap if we have too many layers | ||
if n_visible > 5: | ||
cmap = matplotlib.colormaps['gist_rainbow'].resampled(n_visible) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit worried about two different if-else statements that need to be synced to each other (if we ever change the length of the supported number of presets, we need to update the list above, this if-else, and the if-else in the for loop. Maybe we can create the list of colors before the for-loop and then just access and set them within the for loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I don't love all the conditionals here either. Creating a matplotlib colormap is cheap enough I think I'll just do it anytime there are more than 2 visible layers in that first if statement. Actually, instead of hard-coding numbers, I can check against the length of preset_colors
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if we had (before the for-loop):
if n_visible > len(preset_colors):
preset_colors = [matplotlib.colors.to_hex(cmap(i), keep_alpha=True) for i in range(n_visible)]
and then in the for-loop, just access preset_colors[i]
(or better yet, loop over preset colors as well)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't quite just loop over the preset colors, since we also need to get the right index from the layer list in the loop. I made the other changes though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could loop over both with zip (for visible_layer, preset_color in zip(visible_layers, preset_colors)
) if we don't need to access much else, but this works too
Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Sorry, coming here late. Can you please invert the color scheme? An intuitive workflow would be:
Currently it goes from red to blue. |
Since this PR is merged, do we need a new ticket? |
Nah, that's fast enough I'll just do it without one. |
Pretty self explanatory, I hope. Ready for everyone to try to break it. Demo with 6 layers (note that I changed the button text and decided to set stretch to 99% for all layers since I made this recording):
Screen.Recording.2023-11-09.at.1.31.03.PM.mov