Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Allow setting sketch color default #4979
Allow setting sketch color default #4979
Changes from 7 commits
274c57c
45d5cd7
a3e62c8
e069b28
d9ead21
5348f1d
feaa22b
354c110
8c3a5f6
a7ec405
bd5bee7
6529197
ad53f33
06e8f61
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 don't follow this. Can you explain what's happening?
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.
yep, so previously in the frontend, whenever a user drew a mask, we were drawing it twice - once on the visible layer directly on the image, and then again on a hidden layer called "mask", which instead drew with a white brush on a black background. This mask layer was what was getting sent to the backend on submit.
I simplified the frontend so that there is a single mask layer, now visible, that hovers over the drawing. A user is no longer drawing directly on the image, but instead on this visible mask layer. On submit, we send this mask layer. However, this mask layer is no longer the white on black image of before - it has opacity and may be whatever color that brush_color has been set to. So now we convert this mask layer into the B+W mask of before in the backend with these lines of code.
We support "backwards compatibility" in case someone uses a client, with
if mask_im.mode == "RGBA":
, because previously masks were only RGB.cc @pngwn for context to the frontend changes
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.
Are we certain that this conversion is always accurate (going from colours to b+w, especially since the sketches are antialiased)? Masks are typically alpha layers and lack any colours, I'm curious about why we would ever want a mask layer with colour.
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.
The mask layer only has color because that's how that canvas is rendered now, as a color on a transparent background. I assumed the antialiasing would manifest in the alpha, as in the smooth edges would have an alpha between 0 and 255, which would get translated to some gray between 0 and 255 in the backend logic where we take the alpha value and set it as the R, G, and B values. Will confirm if this antialiasing works.
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.
Confirmed that antialiasing still works - there are values between 0 and 255 at the edges of the mask