Chromatism is a lightweight JavaScript utility library designed for comprehensive color manipulation, offering a rich set of functions for color transformations, conversions, and metering. It supports various color types including RGB, HSL, Hex, CMYK, and can intelligently process mixed input types. The current stable version is 3.0.0, which marked a significant breaking change focused on optimizing for ES Modules (ESM) to achieve the smallest possible bundle sizes. Key differentiators include its strong emphasis on ESM for tree-shaking, the implementation of uniform hue-shifting transforms using HSLuv for more accurate color adjustments, and an efficient internal conversion chain. The library also ships with first-class TypeScript definitions, enhancing developer experience and type safety. While previous major versions supported function chaining, v3.0.0 removed this pattern in favor of a more functional, direct API.
npm install chromatismVerified import paths — ran on the pinned version, not inferred.
Demonstrates core color manipulation functions like conversion, shading, inversion, and generating complementary colors, showcasing various input/output formats.
Refactor chained calls into separate function invocations, passing the output of one function as the input to the next. Access the desired output format via getters like `.hex` or `.rgb` on the returned color object.
If these constants are critical for your application, you may need to implement them manually or consider using an older major version of the library (e.g., v2.x) that still included them. Explore alternative libraries if specific CIE-related constants are needed.
Ensure your project is configured to properly resolve ES Modules (e.g., `"type": "module"` in `package.json` or configuring your bundler like Rollup/Webpack for ESM) and consistently use `import` syntax.
Upgrade to `chromatism` v2.5.8 or a newer version to benefit from the included TypeScript definitions. If upgrading is not feasible, consider installing `@types/chromatism` (if available for your version) or create custom declaration files.
For ES Modules, use `import { someFunction } from 'chromatism';` for individual functions or `import * as chromatism from 'chromatism';` and then `chromatism.someFunction(...)`. If targeting a CommonJS environment that still supports the library, ensure `const chromatism = require('chromatism');` is used before accessing `chromatism.someFunction(...)`.Refactor your code to use individual function calls. For example, instead of `chromatism.chain(color).shade(10).hex`, you would write `const intermediateColor = chromatism.convert(color); const finalColor = chromatism.shade(10, intermediateColor.rgb); const hexValue = finalColor.hex;`
Ensure you are using the full color object returned by chromatism functions to access format getters. For example, `const myColor = chromatism.shade(10, baseColor); myColor.hex;` is correct. If you have a raw `{ r, g, b }` object, convert it first: `chromatism.convert({ r: 255, g: 0, b: 0 }).hex;`No dependency data recorded yet.