Skip to content
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

Support mix-blend-mode compositing in screenshots. #1074

Merged
merged 2 commits into from
Mar 5, 2021

Conversation

manthey
Copy link
Contributor

@manthey manthey commented Mar 1, 2021

There are limitations to the current screenshot function. If layers are composited with mix-blend-mode, svg filters, or some other options, these are not applied. mix-blend-mode support is added here; other limitations remain.

@manthey
Copy link
Contributor Author

manthey commented Mar 1, 2021

As an explicit use case, we have a project where a hyperspectral image (fluorescence microscopy) is shown with one channel per layer. We let the users adjust the color and scaling of each channel in a separate layer and composite them via the mix-blend-mode: lighter option. We want to take a screenshot of the current settings, and this change is needed to composite the results correctly.

@manthey manthey requested a review from aashish24 March 1, 2021 15:27
@manthey manthey force-pushed the screenshot-mix-blend-mode branch from 0d50779 to e6f2e1d Compare March 2, 2021 13:33
There are limitations to the current screenshot function.  If layers are
composited with mix-blend-mode, svg filters, or some other options,
these are not applied.  mix-blend-mode support is added here; other
limitations remain.
@manthey manthey force-pushed the screenshot-mix-blend-mode branch from e6f2e1d to 9bbf038 Compare March 2, 2021 13:53
In some environments, this seems to resolve transient test failures.
@aashish24
Copy link
Member

Doing the review now

context.globalAlpha = opacity;
if (mixBlendMode) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be not possible to just have the user pass any one type of globalCompositeOperation (source in/out, over etc?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, any of the globalCompositeOperation values are supported. They are called mix-blend-mode in css and globalCompositeOperation in canvas.

@@ -62,6 +62,6 @@ describe('blog-lines example', function () {
// this permits a large delta to pass on CI. It visually is rendered
// correctly, though with seemingly different aliasing choices by the
// renderer
imageTest.imageTest('exampleBlogLines10k', '#map', 0.04, done, null, 1000, 2, '.geojs-map.ready');
imageTest.imageTest('exampleBlogLines10k', '#map', 0.04, done, null, 5000, 2, '.geojs-map.ready');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this increase to 5000?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Travis was timing out on this. I don't know why, but increasing it allowed the tests to pass. It is like they are using a different mesa library than before that is slower, but that is just speculation.

@manthey manthey merged commit 27fac50 into master Mar 5, 2021
@manthey manthey deleted the screenshot-mix-blend-mode branch March 5, 2021 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants