-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Re-enable the setting to adjust the colors of indistinguishable text #13343
Conversation
In a follow-up, we will change the setting from a boolean value to an enum with 3 possible values: 'Never' to never adjust the text, 'Indexed' to only adjust the text if both the foreground/background are part of the current color scheme's color table (this is today's behaviour when the setting is set to "true"), and "Always" to always adjust the text if it is indistinguishable (this will be somewhat performance intensive since we will be calculating this at render time, but that is why it will be opt-in only) |
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 quite understand why we shouldn't nudge brightened colors. 🤔
If performance turns out to be a problem we can use "redmean" still as I suggested offhand a while ago. I suspect it would work sufficiently well to determine a JND, since always nudging colors by 5 lightness is in a way a lot less "scientific" than the DeltaE algorithm itself, defeating its purpose a bit. This is the entire algorithm btw (output range 0-765): double redmean(COLORREF c1, COLORREF c2) {
int r1 = GetRValue(c1), g1 = GetGValue(c1), b1 = GetBValue(c1);
int r2 = GetRValue(c2), g2 = GetGValue(c2), b2 = GetBValue(c2);
int dr = r1 - r2;
int dg = g1 - g2;
int db = b1 - b2;
int rmean = (r1 + r2) / 2;
return sqrt((512 + rmean) * dr * dr / 256 + 4 * dg * dg + (767 - rmean) * db * db / 256);
} |
The issue arises when the colors are reversed and the foreground is bright - we will need to calculate what 'bright background' means but we don't have an easy way to do that |
PR has changed a little (sorry!!)
(Noting @j4james here, as he said "Finally, I think having bold in the color table is an essential prerequisite for getting the bold color to work when the option to Automaticaly adjust lightness of indistinguishable text is enabled (see #11917).". We did not end up choosing to fix 11939 beforehand, but may take the fix introduced here as a TODO on landing #11939. I would rather totally get rid of |
LOL. Clearly I was wrong, since the bold seems to working fine in this PR as far as I can tell. That said, I still think this functionality should probably not be enabled by default, because there are going to be edges cases that don't work, and that's kind of inevitable when we're deliberately choosing to alter the colors that were requested. As one example, if you're using a "standard" color scheme, like Campbell, where the default background is identical to black, and the default foreground is identical to white, then both these sequences should be invisible, but they aren't:
That particular case may be fixable, but there'll always be something. Having the default behavior be technically incorrect feels like we're asking for bug reports. |
I don't know how well this would work in practice, but one idea I had for improving the performance was to move the color remapping from the renderer to the |
I've had a think about this over the weekend. 🧠🤔 If we picture RGB colors as a 3D space and simplify things a bit, then the area below the JND (just-noticeable-difference of color) forms a simple sphere around our reference color. Within this coordinate system grayscale is the unit vector Of course the problem is that the MacAdam ellipse (the range of colors within the JND) is an ellipse/ellipsoid and not a sphere, but as mentioned before, redmean is a simple algorithm that apparently works sufficiently well and would allow us to scale the RGB axes to get an ellipsoid. The 3 scales would be, where
Scaling the coordinates down by these factors ("squishing" the coordinate space), doing the line-sphere intersection and then scaling it back up should yield us appropriate results I believe. In either case, in my testing this calculation can be done without any caching at all in real time (it wouldn't even show up in a perf trace) and (in a more limited testing) it seems to produce equally well adjusted colors. (Only the |
Had a chat with @lhecker, turns out the red-mean algorithm is not quite robust enough and just doesn't work as well as the delta e one. So we will stick to this algorithm for now and in the future come back to optimizing the delta e algorithm (Leonard has several ideas for how we can do this). I've also switched the setting back to default off as per James' suggestion |
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 cool with this, but I'm gonna leave automerge off to give Dustin a last chance at it.
Hello @zadjii-msft! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
…boolean setting (#13512) ## Summary of the Pull Request `AdjustIndistinguishableColors` can now be set to: - `Never`: Never adjust the colors - `Indexed`: Only adjust colors that are part of the color scheme - `Always`: Always adjust the colors ## References #13343 ## PR Checklist * [ ] Closes #xxx * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [ ] Schema updated. * [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx ## Detailed Description of the Pull Request / Additional comments For legacy purposes, `true` and `false` map to `Indexed` and `Never` respectively ## Validation Steps Performed Setting still works
🎉 Handy links: |
Hi, could you show an example of the relevant section of settings file where to enable this feature? |
aha, figured out. scroll to "profiles" to add it
|
Summary of the Pull Request
Re-enable the setting to adjust indistinguishable text, with some changes:
References
#11095 #12160
PR Checklist
Validation Steps Performed
Indistinguishable text gets adjusted again