Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@types/chroma-js
Advanced tools
TypeScript definitions for chroma-js
@types/chroma-js provides TypeScript type definitions for the chroma-js library, which is a JavaScript library for color conversions and color scales.
Color Conversion
This feature allows you to convert colors between different formats. In this example, the color 'red' is converted to its RGB representation.
const chroma = require('chroma-js');
const rgb = chroma('red').rgb();
console.log(rgb); // [255, 0, 0]
Color Scales
This feature allows you to create color scales. In this example, a scale from white to black is created and the color at the midpoint (0.5) is retrieved in hex format.
const chroma = require('chroma-js');
const scale = chroma.scale(['white', 'black']).mode('lab');
console.log(scale(0.5).hex()); // #777777
Color Manipulation
This feature allows you to manipulate colors. In this example, the color 'red' is darkened and the resulting color is retrieved in hex format.
const chroma = require('chroma-js');
const darkened = chroma('red').darken().hex();
console.log(darkened); // #8b0000
Color Blending
This feature allows you to blend two colors using different blending modes. In this example, 'red' and 'blue' are blended using the 'multiply' mode.
const chroma = require('chroma-js');
const blended = chroma.blend('red', 'blue', 'multiply').hex();
console.log(blended); // #000080
The 'color' package is a JavaScript library for color conversions and manipulations. It provides similar functionalities to chroma-js, such as color parsing, conversion, and manipulation, but it does not focus on color scales.
The 'tinycolor2' package is another JavaScript library for color manipulation and conversion. It offers a wide range of color operations and is known for its small size and ease of use. It is similar to chroma-js but does not provide as extensive support for color scales.
The 'd3-color' package is part of the D3.js library and provides color manipulation and conversion functionalities. It is similar to chroma-js in terms of color operations but is more integrated into the D3 ecosystem for data visualization.
npm install --save @types/chroma-js
This package contains type definitions for chroma-js (https://github.com/gka/chroma.js).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/chroma-js.
These definitions were written by Sebastian Brückner, Marcin Pacholec, and Charlie Zhuo.
FAQs
TypeScript definitions for chroma-js
The npm package @types/chroma-js receives a total of 305,682 weekly downloads. As such, @types/chroma-js popularity was classified as popular.
We found that @types/chroma-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.