![]() ![]() So, any of these are valid hexadecimal representations: #ff3399, FF3399, #f39, etc. It ignores case, the # sign is optional, and it can recognize the shorter three letter format as well. If there's no matching named color, chroma.js checks for a hexadecimal string. For instance, it will recognize any named color from the W3CX11 specification: chroma('hotpink') This function attempts to guess the format of the input color for you. That's what the generic constructor chroma() does. The first step is to get your color into chroma.js. chroma.scale()Ĭhroma.js has a lot more to offer, but that's the gist of it. Here's an example for a simple read / manipulate / output chain: chroma('pink').darken().saturate(2).hex()Īside from that, chroma.js can also help you generate nice colors using various methods, for instance to be used in color palette for maps or data visualization. linear and bezier interpolation in different color spaces.convert colors into wide range of formats.read colors from a wide range of formats.Here are a couple of things chroma.js can do for you: Or use it from SASS using chromatic-sass! Quick-start The interactive documentation continues below (and there's a static version, too) for usage examples. Then, initiate and manipulate colors: chroma('#D4F880').darken().hex() // #9BC04B Then import the module into your JavaScript: import chroma from "chroma-js".Īnd for browsers, download or use the hosted version on. Chroma.js is a small-ish zero-dependency JavaScript library ( 13.5kB) for all kinds of color conversions and color scales.įor Node.js: Install the chroma-js npm module, npm install chroma-js.
0 Comments
Leave a Reply. |