mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibGfx: Use a more explicit formula in Color::from_linear_srgb
NFC. I prefer having the constants expanded, it makes it easier to trace them back to the initial formula.
This commit is contained in:
parent
a59d9a3986
commit
f949334a9a
Notes:
github-actions[bot]
2024-11-16 09:31:01 +00:00
Author: https://github.com/LucasChollet Commit: https://github.com/LadybirdBrowser/ladybird/commit/f949334a9a8 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2374
1 changed files with 3 additions and 1 deletions
|
@ -399,7 +399,9 @@ Vector<Color> Color::tints(u32 steps, float max) const
|
|||
Color Color::from_linear_srgb(float red, float green, float blue, float alpha)
|
||||
{
|
||||
auto linear_to_srgb = [](float c) {
|
||||
return c >= 0.0031308f ? 1.055f * pow(c, 0.4166666f) - 0.055f : 12.92f * c;
|
||||
if (c <= 0.04045 / 12.92)
|
||||
return c * 12.92;
|
||||
return pow(c, 10. / 24) * 1.055 - 0.055;
|
||||
};
|
||||
|
||||
red = linear_to_srgb(red) * 255.f;
|
||||
|
|
Loading…
Reference in a new issue