1.0.1 • Published 10 months ago

js-tool-color v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

Color-Tool

Color tool is a library of color processing tools that supports HXL, RGB, HSL format processing and conversion, provides a variety of color blending, extraction, linear change, random generation, interpolation, similarity analysis, accent color generation, and supports 140 browser-supported default colors and multiple sets of colors

Installation

npm install js-tool-color

Usage

//First import the Color-tool library
const Color = require('js-tool-color');

//You can then use the methods in the library
let checkColor = Color.checks('rgba(255,255,255,1)')

//It is worth noting that if you try to extend a method with a plugin, be sure to execute the following code before using the method
const yourPlugin = {} //Your plugin
Color.plugin(yourPlugin).run()

Api

nameparametersdescription
addDefinekey,valueAdds a color definition.
blendingcolors,colors,typeBlends multiple colors together according to a specified blending mode.
changeColorcolorThis function changes the value of a single color channel (red, green, blue, alpha) in a given color.
checkcolorColor detection, standardized processing methods
checkscolorThis function accepts a color string, identifies its type (Hex, RGB, RGBA, HSL, HSLA), and returns a new object containing the color's value in different formats and some related functions.
colorThemecolor,theme,typeGenerates colors following a certain theme.
complementcolor,typeThis function returns the complementary color of the given color.
contrastcolors,contrast,typeThis function adjusts the contrast of an array of colors.
getColorcolorReturns a color value from the color definitions, if it exists.
getThemeColorstype, themeGets a specific color set from a theme.
hslaAdjustmentcolor,typeThis function adjusts the HSLA values of a given color.
inversioncolor,typeThis function inverts the color and alpha channel of a given color.
labToRgbcolorConverts a Lab color to an RGB color.
lerpColorcolor1, color2, t, name, typeThis function performs a linear interpolation between two colors based on a given ratio.
linearColorstart, end, intervalGenerates a function that gives the linear interpolated color at a specific time.
linearColorscolor1, color2, interval, typeGenerates a function that returns linear interpolated colors between two colors for a specific time.
multilinearColorcolors, intervalGenerates a function that returns multilinear interpolated colors among several colors for a specific time.
multilinearColorscolors, interval, typeGenerates a function that returns multilinear interpolated colors among several colors for a specific time.
pluginplugsRegisters plugins to the library.
randomColorstart, endGenerates a random color within the given range.
removeDefinekeyRemoves a color definition.
rgbToLabcolorConverts an RGB color to a Lab color.
seqLevelscolor1, color2, levels, typeCreates a sequence of color levels between two colors.
shadecolor, percentage, typeThis function shades a color by mixing it with black using linear interpolation.
similarityHslacolor1, color2This function calculates the similarity between two colors in the HSLA color space.
similarityRgbacolor1, color2This function calculates the similarity between two colors in the RGBA color space.
tintcolor, percentage, typeThis function tints a color by mixing it with white using linear interpolation.
toTypecolor, typeConverts a color to a specific color format.
transformationcolorTransforms the input color from rgb to hex or vice versa.

For complete API documentation, see API documentation

License

This project is licensed under the MIT License - see the LICENSE file for details

1.0.1

10 months ago

1.0.0

10 months ago