dd5dbb2a40
- Implements the Delta E algorithm - Uses the Delta E algorithm to precalculate adjusted foreground values based on possible foreground/background color pairs in the color table - Adds a setting to use the adjusted foreground values when applicable ## PR Checklist * [x] Closes #2638 * [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 work here ## Validation Steps Performed Before: <img width="759" alt="color before" src="https://user-images.githubusercontent.com/26824113/131576768-b3b9eebd-5933-45de-8da8-88a985070312.png"> After (note dark blue): <img width="760" alt="color after" src="https://user-images.githubusercontent.com/26824113/133158807-4e63198f-8a49-4d03-914e-55a5ad57d725.png">
50 lines
949 B
C++
50 lines
949 B
C++
/*++
|
|
Copyright (c) Microsoft Corporation
|
|
Licensed under the MIT license.
|
|
|
|
Module Name:
|
|
- ColorFix
|
|
|
|
Abstract:
|
|
- Implementation of perceptual color nudging, which allows the Terminal
|
|
to slightly shift the foreground color to make it more perceivable on
|
|
the current background (for cases where the foreground is very close
|
|
to being imperceivable on the background).
|
|
|
|
Author(s):
|
|
- Pankaj Bhojwani - Sep 2021
|
|
|
|
--*/
|
|
|
|
#pragma once
|
|
|
|
struct ColorFix
|
|
{
|
|
public:
|
|
ColorFix(COLORREF color);
|
|
|
|
static COLORREF GetPerceivableColor(COLORREF fg, COLORREF bg);
|
|
|
|
// RGB
|
|
union
|
|
{
|
|
struct
|
|
{
|
|
BYTE r, g, b, dummy;
|
|
};
|
|
COLORREF rgb;
|
|
};
|
|
|
|
// Lab
|
|
struct
|
|
{
|
|
double L, A, B;
|
|
};
|
|
|
|
private:
|
|
static double _GetHPrimeFn(double x, double y);
|
|
static double _GetDeltaE(ColorFix x1, ColorFix x2);
|
|
void _ToLab();
|
|
void _ToRGB();
|
|
};
|