forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🤖 Merge PR DefinitelyTyped#69771 culori: Add XYB colorspace, missing …
…fns, and culori/css + culori/all entry points by @drwpow
- Loading branch information
Showing
15 changed files
with
223 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export { | ||
a98, | ||
cubehelix, | ||
dlab, | ||
dlch, | ||
hsi, | ||
hsl, | ||
hsv, | ||
hwb, | ||
jab, | ||
jch, | ||
lab, | ||
lab65, | ||
lch, | ||
lch65, | ||
lchuv, | ||
lrgb, | ||
luv, | ||
okhsl, | ||
okhsv, | ||
oklab, | ||
oklch, | ||
p3, | ||
prophoto, | ||
rec2020, | ||
rgb, | ||
xyb, | ||
xyz50, | ||
xyz65, | ||
yiq, | ||
} from "../index"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export { | ||
a98, | ||
hsl, | ||
hsv, | ||
hwb, | ||
lab, | ||
lab65, | ||
lch, | ||
lch65, | ||
lrgb, | ||
oklab, | ||
oklch, | ||
p3, | ||
prophoto, | ||
rec2020, | ||
rgb, | ||
xyz50, | ||
xyz65, | ||
} from "../index"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,84 @@ | ||
import { Color, GamutMode, Mode } from "./common"; | ||
import { Color, FindColorByMode, GamutMode, Mode } from "./common"; | ||
|
||
/** | ||
* Returns whether the color is in the sRGB gamut. | ||
*/ | ||
export function displayable(color: Color | string): boolean; | ||
|
||
/** | ||
* Given a color space `mode`, returns a function | ||
* with which to check whether a color is | ||
* in that color space's gamut. | ||
*/ | ||
export function inGamut(mode?: Mode): (color: Color | string) => boolean; | ||
|
||
/* | ||
* Obtain a color that's in the sRGB gamut | ||
* by converting it to sRGB and clipping the channel values | ||
* so that they're within the [0, 1] range. | ||
* | ||
* The result is returned in the color's original color space. | ||
*/ | ||
export function clampRgb(color: string): Color | undefined; | ||
export function clampRgb<C extends Color>(color: C): C; | ||
|
||
export function clampChroma(color: string, mode?: Mode, rgbGamut?: GamutMode): Color | undefined; | ||
/** | ||
* Given the `mode` color space, returns a function | ||
* with which to obtain a color that's in gamut for | ||
* the `mode` color space by clipping the channel values | ||
* so that they fit in their respective ranges. | ||
* | ||
* It's similar to `clampRgb`, but works for any | ||
* bounded color space (RGB or not) for which | ||
* any combination of in-range channel values | ||
* produces an in-gamut color. | ||
*/ | ||
export function clampGamut<M extends Mode = "rgb">(mode?: M): (color: Color | string) => FindColorByMode<M> | undefined; | ||
|
||
/** | ||
* Obtain a color that’s in a RGB gamut (by default sRGB) | ||
* by first converting it to `mode` and then finding | ||
* the greatest chroma value that fits the gamut. | ||
* | ||
* By default, the CIELCh color space is used, | ||
* but any color that has a chroma component will do. | ||
* | ||
* The result is returned in the color's original color space. | ||
*/ | ||
export function clampChroma( | ||
color: string, | ||
mode?: Mode, | ||
rgbGamut?: GamutMode, | ||
): Color | undefined; | ||
export function clampChroma<C extends Color>(color: C, mode?: Mode, rgbGamut?: GamutMode): C; | ||
|
||
/* | ||
* Obtain a color that's in the `dest` gamut, | ||
* by first converting it to the `mode` color space | ||
* and then finding the largest chroma that's in gamut, | ||
* similar to `clampChroma`. | ||
* | ||
* The color returned is in the `dest` color space. | ||
* | ||
* To address the shortcomings of `clampChroma`, which can | ||
* sometimes produce colors more desaturated than necessary, | ||
* the test used in the binary search is replaced with | ||
* "is color is roughly in gamut", by comparing the candidate | ||
* to the clipped version (obtained with `clampGamut`). | ||
* The test passes if the colors are not too dissimilar, | ||
* judged by the `delta` color difference function | ||
* and an associated `jnd` just-noticeable difference value. | ||
* | ||
* The default arguments for this function correspond to the | ||
* gamut mapping algorithm defined in CSS Color Level 4: | ||
* https://drafts.csswg.org/css-color/#css-gamut-mapping | ||
* | ||
* To disable the “roughly in gamut” part, pass either | ||
* `null` for the `delta` parameter, or zero for `jnd`. | ||
*/ | ||
export function toGamut<M extends Mode>( | ||
dest: M, | ||
mode: Mode, | ||
delta?: number | null, | ||
jnd?: number, | ||
): (color: string | Color) => FindColorByMode<M>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const bias: number; | ||
export const bias_cbrt: number; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Rgb } from "../rgb/types"; | ||
import { Xyb } from "./types"; | ||
|
||
declare function convertRgbToXyb(rgb: Omit<Rgb, "mode">): Xyb; | ||
|
||
export default convertRgbToXyb; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Rgb } from "../rgb/types"; | ||
import { Xyb } from "./types"; | ||
|
||
declare function convertXybToRgb(color: Omit<Xyb, "mode">): Rgb; | ||
|
||
export default convertXybToRgb; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { fixupAlpha } from "../fixup/alpha"; | ||
import { interpolatorLinear } from "../interpolate/linear"; | ||
import convertRgbToXyb from "./convertRgbToXyb"; | ||
import convertXybToRgb from "./convertXybToRgb"; | ||
|
||
declare const definition: { | ||
mode: "xyb"; | ||
parse: ["xyz-d50", "--xyz-d50"]; | ||
serialize: "xyz-d50"; | ||
|
||
toMode: { | ||
rgb: typeof convertXybToRgb; | ||
}; | ||
|
||
fromMode: { | ||
rgb: typeof convertRgbToXyb; | ||
}; | ||
|
||
channels: ["x", "y", "z", "alpha"]; | ||
|
||
ranges: { | ||
x: [0, 0.964]; | ||
y: [0, 0.999]; | ||
z: [0, 0.825]; | ||
}; | ||
|
||
interpolate: { | ||
x: typeof interpolatorLinear; | ||
y: typeof interpolatorLinear; | ||
b: typeof interpolatorLinear; | ||
alpha: { use: typeof interpolatorLinear; fixup: typeof fixupAlpha }; | ||
}; | ||
}; | ||
|
||
export default definition; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface Xyb { | ||
mode: "xyb"; | ||
x: number; | ||
y: number; | ||
b: number; | ||
alpha?: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters