https://github.com/antvis/smart-color
A JavaScript library for color computation.
https://github.com/antvis/smart-color
Last synced: 9 months ago
JSON representation
A JavaScript library for color computation.
- Host: GitHub
- URL: https://github.com/antvis/smart-color
- Owner: antvis
- License: mit
- Created: 2021-06-21T10:28:28.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-09-28T03:28:08.000Z (almost 3 years ago)
- Last Synced: 2025-09-15T18:41:26.852Z (10 months ago)
- Language: TypeScript
- Homepage: https://antv.vision/smart-color/
- Size: 5.03 MB
- Stars: 30
- Watchers: 10
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
@antv/smart-color
A JavaScript library for color computation.
## ✨ Features
* **Palette Generation**: Generate categorical or discrete scale palette based on [color scheme](https://github.com/neoddish/color-palette-json-schema#colorschemetype).
* **Palette Optimization**: Optimize palette to enhance color discriminability.
* **Palette Extraction**: Get palettes from strings and images.
* **Color Simulation**: Simulate color blindness and color in grayscale.
* **Color Evaluation**: Evaluate color discriminability and aesthetics.
* **Color Computation**: Blend colors, brighten or darken colors.
* **Color Conversion**: Convert color into different formats.
## 📦 Installation
```bash
$ npm install @antv/smart-color
```
## 🔨 Getting Started
* Palette Generation
```ts
import { paletteGeneration } from '@antv/smart-color';
paletteGeneration("monochromatic", {
color: {
model: "rgb",
value: { r: 91, g: 143, b: 249 },
},
count: 7,
tendency: "shade"
});
```
* Palette Optimization
```ts
import { PaletteOptimization } from '@antv/smart-color';
const palette = {
name: "color4",
semantic: null,
type: "categorical",
colors: [
{ model: "rgb", value: { r: 101, g: 120, b: 155 }, },
{ model: "rgb", value: { r: 91, g: 143, b: 249 }, },
{ model: "rgb", value: { r: 97, g: 221, b: 170 }, },
{ model: "rgb", value: { r: 246, g: 189, b: 22 }, }
],
}
paletteOptimization(palette, {
locked: [true],
simulationType: "grayscale"
});
```
Before:
After:
* Color Simulation
```ts
import { colorSimulation } from '@antv/smart-color';
const color = {
model: "rgb",
value: { r: 91, g: 143, b: 249 },
}
colorSimulation(color, "achromatomaly");
```
## 🔗 Links
* [API Reference](./docs/api/readme.md)
## License
MIT