Skip to content

Commit 488c9f4

Browse files
authored
Merge pull request #215 from dkryaklin/fix-low-lightness-gamut-spike
Tighten sRGB gamut tolerance to remove low-L spike
2 parents c20f3e0 + 5954f86 commit 488c9f4

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

lib/colors.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export let lrgb = useMode(modeLrgb)
5050
export let p3 = useMode(modeP3)
5151

5252
const COLOR_SPACE_GAP = 0.0001
53+
const RENDER_GAP = 1e-7
5354

5455
// Dirty fix of https://github.com/Evercoder/culori/issues/249
5556
export function inRGB(color: Color): boolean {
@@ -249,12 +250,12 @@ export interface GetColor {
249250

250251
function inGamutEps(r: number, g: number, b: number): boolean {
251252
return (
252-
r >= -COLOR_SPACE_GAP &&
253-
r <= 1 + COLOR_SPACE_GAP &&
254-
g >= -COLOR_SPACE_GAP &&
255-
g <= 1 + COLOR_SPACE_GAP &&
256-
b >= -COLOR_SPACE_GAP &&
257-
b <= 1 + COLOR_SPACE_GAP
253+
r >= -RENDER_GAP &&
254+
r <= 1 + RENDER_GAP &&
255+
g >= -RENDER_GAP &&
256+
g <= 1 + RENDER_GAP &&
257+
b >= -RENDER_GAP &&
258+
b <= 1 + RENDER_GAP
258259
)
259260
}
260261

0 commit comments

Comments
 (0)