diff --git a/package.json b/package.json index 48fd6de..7faabf4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tinygradient", - "version": "0.4.0", + "version": "0.4.1", "author": { "name": "Damien \"Mistic\" Sorel", "email": "contact@git.strangeplanet.fr", @@ -34,6 +34,7 @@ "url": "https://github.com/mistic100/tinygradient/issues" }, "scripts": { + "build": "grunt", "test": "grunt test" } } diff --git a/tinygradient.d.ts b/tinygradient.d.ts index 8d908e1..cbe9693 100644 --- a/tinygradient.d.ts +++ b/tinygradient.d.ts @@ -1,119 +1,126 @@ /*! - * TinyGradient 0.4.0 + * TinyGradient 0.4.1 * Copyright 2014-2018 Damien "Mistic" Sorel (http://www.strangeplanet.fr) * Licensed under MIT (http://opensource.org/licenses/MIT) */ -declare var tinygradient: tinygradient; - -type ArcMode = boolean | 'short' | 'long'; - -interface TinyGradient { - - /** - * Return new instance with reversed stops - * @return {tinygradient} - */ - reverse(): tinygradient; - - /** - * Generate gradient with RGBa interpolation - * @param {int} steps - * @return {tinycolorInstance[]} - */ - rgb(steps: number): tinycolorInstance[]; - - /** - * Generate gradient with HSVa interpolation - * @param {int} steps - * @param {Boolean|String} [mode=false] - * - false to step in clockwise - * - true to step in trigonometric order - * - 'short' to use the shortest way - * - 'long' to use the longest way - * @return {tinycolorInstance[]} - */ - hsv(steps: number, mode: ArcMode): tinycolorInstance[]; - - /** - * Generate CSS3 command (no prefix) for this gradient - * @param {String} [mode=linear] - 'linear' or 'radial' - * @param {String} [direction] - default is 'to right' or 'ellipse at center' - * @return {String} - */ - css(mode?: 'linear' | 'radial', direction?: string): string; - - /** - * Returns the color at specific position with RGBa interpolation - * @param {float} pos, between 0 and 1 - * @return {tinycolorInstance} - */ - rgbAt(pos: number): tinycolorInstance; - - /** - * Returns the color at specific position with HSVa interpolation - * @param {float} pos, between 0 and 1 - * @return {tinycolorInstance} - */ - hsvAt(pos: number): tinycolorInstance; - -} - -interface tinygradient { - /** - * @class tinygradient - * @param {ColorInput[]} stops - */ - (stops: ColorInput[]): TinyGradient; - - /** - * Generate gradient with RGBa interpolation - * @param {ColorInput[]} stops - * @param {int} steps - * @return {tinycolorInstance[]} - */ - rgb(stops: ColorInput[], steps: number): tinycolorInstance[]; - - /** - * Generate gradient with HSVa interpolation - * @param {ColorInput[]} stops - * @param {int} steps - * @param {Boolean|String} [mode=false] - * - false to step in clockwise - * - true to step in trigonometric order - * - 'short' to use the shortest way - * - 'long' to use the longest way - * @return {tinycolorInstance[]} - */ - hsv(stops: ColorInput[], steps: number, mode: ArcMode): tinycolorInstance[]; - - /** - * Generate CSS3 command (no prefix) for this gradient - * @param {ColorInput[]} stops - * @param {String} [mode=linear] - 'linear' or 'radial' - * @param {String} [direction] - default is 'to right' or 'ellipse at center' - * @return {String} - */ - css(stops: ColorInput[], mode?: 'linear' | 'radial', direction?: string): string; - - /** - * Returns the color at specific position with RGBa interpolation - * @param {ColorInput[]} stops - * @param {float} pos, between 0 and 1 - * @return {tinycolorInstance} - */ - rgbAt(stops: ColorInput[], pos: number): tinycolorInstance; - - /** - * Returns the color at specific position with HSVa interpolation - * @param {ColorInput[]} stops - * @param {float} pos, between 0 and 1 - * @return {tinycolorInstance} - */ - hsvAt(stops: ColorInput[], pos: number): tinycolorInstance; +import * as tinycolor from 'tinycolor2'; + +declare namespace tinygradient { + + type ArcMode = boolean | 'short' | 'long'; + + type CssMode = 'linear' | 'radial'; + + interface Instance { + + /** + * Return new instance with reversed stops + * @return {Instance} + */ + reverse(): Instance; + + /** + * Generate gradient with RGBa interpolation + * @param {int} steps + * @return {tinycolor.Instance[]} + */ + rgb(steps: number): tinycolor.Instance[]; + + /** + * Generate gradient with HSVa interpolation + * @param {int} steps + * @param {ArcMode} [mode=false] + * - false to step in clockwise + * - true to step in trigonometric order + * - 'short' to use the shortest way + * - 'long' to use the longest way + * @return {tinycolor.Instance[]} + */ + hsv(steps: number, mode: ArcMode): tinycolor.Instance[]; + + /** + * Generate CSS3 command (no prefix) for this gradient + * @param {CssMode} [mode=linear] - 'linear' or 'radial' + * @param {String} [direction] - default is 'to right' or 'ellipse at center' + * @return {String} + */ + css(mode?: CssMode, direction?: string): string; + + /** + * Returns the color at specific position with RGBa interpolation + * @param {double} pos, between 0 and 1 + * @return {tinycolor.Instance} + */ + rgbAt(pos: number): tinycolor.Instance; + + /** + * Returns the color at specific position with HSVa interpolation + * @param {float} pos, between 0 and 1 + * @return {tinycolor.Instance} + */ + hsvAt(pos: number): tinycolor.Instance; + + } + + interface Constructor { + /** + * @class tinygradient + * @param {tinycolor.ColorInput[]} stops + */ + new (stops: tinycolor.ColorInput[]): Instance; + new (...stops: tinycolor.ColorInput[]): Instance; + (stops: tinycolor.ColorInput[]): Instance; + (...stops: tinycolor.ColorInput[]): Instance; + + /** + * Generate gradient with RGBa interpolation + * @param {tinycolor.ColorInput[]} stops + * @param {int} steps + * @return {tinycolor.Instance[]} + */ + rgb(stops: tinycolor.ColorInput[], steps: number): tinycolor.Instance[]; + + /** + * Generate gradient with HSVa interpolation + * @param {tinycolor.ColorInput[]} stops + * @param {int} steps + * @param {ArcMode} [mode=false] + * - false to step in clockwise + * - true to step in trigonometric order + * - 'short' to use the shortest way + * - 'long' to use the longest way + * @return {tinycolor.Instance[]} + */ + hsv(stops: tinycolor.ColorInput[], steps: number, mode: ArcMode): tinycolor.Instance[]; + + /** + * Generate CSS3 command (no prefix) for this gradient + * @param {tinycolor.ColorInput[]} stops + * @param {CssMode} [mode=linear] - 'linear' or 'radial' + * @param {String} [direction] - default is 'to right' or 'ellipse at center' + * @return {String} + */ + css(stops: tinycolor.ColorInput[], mode?: CssMode, direction?: string): string; + + /** + * Returns the color at specific position with RGBa interpolation + * @param {tinycolor.ColorInput[]} stops + * @param {float} pos, between 0 and 1 + * @return {tinycolor.Instance} + */ + rgbAt(stops: tinycolor.ColorInput[], pos: number): tinycolor.Instance; + + /** + * Returns the color at specific position with HSVa interpolation + * @param {tinycolor.ColorInput[]} stops + * @param {float} pos, between 0 and 1 + * @return {tinycolor.Instance} + */ + hsvAt(stops: tinycolor.ColorInput[], pos: number): tinycolor.Instance; + } } -// export default tinygradient; -declare module 'tinygradient' { - export = tinygradient; -} +declare const tinygradient: tinygradient.Constructor; +export = tinygradient; +export as namespace tinygradient; diff --git a/tinygradient.js b/tinygradient.js index e8b2ee6..3f83ada 100644 --- a/tinygradient.js +++ b/tinygradient.js @@ -1,5 +1,5 @@ /*! - * TinyGradient 0.4.0 + * TinyGradient 0.4.1 * Copyright 2014-2018 Damien "Mistic" Sorel (http://www.strangeplanet.fr) * Licensed under MIT (http://opensource.org/licenses/MIT) */ diff --git a/tinygradient.min.js b/tinygradient.min.js index 0236d7a..0ffa2f8 100644 --- a/tinygradient.min.js +++ b/tinygradient.min.js @@ -1,5 +1,5 @@ /*! - * TinyGradient 0.4.0 + * TinyGradient 0.4.1 * Copyright 2014-2018 Damien "Mistic" Sorel (http://www.strangeplanet.fr) * Licensed under MIT (http://opensource.org/licenses/MIT) */