mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
[chroma-js] updates types to v1.4.0 (#29150)
* [chroma-js] updates types to v1.4.0 - optional `mode` param for `Color.hex` - `Color.num()` was officially documented, so exposed in @types as well refs: https://github.com/gka/chroma.js/blob/master/CHANGELOG.md https://gka.github.io/chroma.js/#color-hex https://gka.github.io/chroma.js/#color-num * Remove extra empty line * Remove extra whitespace
This commit is contained in:
@@ -82,6 +82,9 @@ function test_color() {
|
||||
chroma('aquamarine').luminance(0.5, 'lab');
|
||||
chroma('aquamarine').luminance(0.5, 'hsl');
|
||||
chroma('orange').hex();
|
||||
chroma('orange').hex('auto');
|
||||
chroma('orange').hex('rgb');
|
||||
chroma('orange').alpha(0.5).hex('rgba');
|
||||
chroma('#ffa500').name();
|
||||
chroma('#ffa505').name();
|
||||
chroma('teal').css();
|
||||
@@ -107,6 +110,11 @@ function test_color() {
|
||||
chroma('teal').alpha(0.5).css();
|
||||
chroma('teal').css('hsl');
|
||||
chroma('orange').rgb();
|
||||
|
||||
chroma('#000000').num();
|
||||
chroma('#0000ff').num();
|
||||
chroma('#00ff00').num();
|
||||
chroma('#ff0000').num();
|
||||
}
|
||||
|
||||
function test_scale() {
|
||||
|
||||
26
types/chroma-js/index.d.ts
vendored
26
types/chroma-js/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Chroma.js 1.3
|
||||
// Type definitions for Chroma.js 1.4
|
||||
// Project: https://github.com/gka/chroma.js
|
||||
// Definitions by: Sebastian Brückner <https://github.com/invliD>, Marcin Pacholec <https://github.com/mpacholec>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -260,9 +260,18 @@ declare namespace chroma {
|
||||
luminance(l: number, colorSpace?: keyof ColorSpaces): Color;
|
||||
|
||||
/**
|
||||
* Get color as hexadecimal string. E.g. '#ffa500'
|
||||
* Get color as hexadecimal string.
|
||||
*
|
||||
* @param mode `auto` - string will include alpha channel only if it's less than 1.
|
||||
* `rgb` - string will not include alpha channel.
|
||||
* `rgba` - string will include alpha channel.
|
||||
*
|
||||
* @example
|
||||
* chroma('orange').hex() === '#ffa500'
|
||||
* chroma('orange').alpha(0.5).hex() === '#ffa50080'
|
||||
* chroma('orange').alpha(0.5).hex('rgb') === '#ffa500'
|
||||
*/
|
||||
hex(): string;
|
||||
hex(mode?: 'auto' | 'rgb' | 'rgba'): string;
|
||||
|
||||
/**
|
||||
* Returns the named color. Falls back to hexadecimal RGB string, if the color isn't present.
|
||||
@@ -280,6 +289,17 @@ declare namespace chroma {
|
||||
* [temperature gradient]{@link ChromaStatic.temperature} above.
|
||||
*/
|
||||
temperature(): number;
|
||||
|
||||
/**
|
||||
* Returns the numeric representation of the hexadecimal RGB color.
|
||||
*
|
||||
* @example
|
||||
* chroma('#000000').num() === 0
|
||||
* chroma('#0000ff').num() === 255
|
||||
* chroma('#00ff00').num() === 65280
|
||||
* chroma('#ff0000').num() === 16711680
|
||||
*/
|
||||
num(): number;
|
||||
} & {
|
||||
[K in keyof ColorSpaces]: () => ColorSpaces[K];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user