@antv/smart-color
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

@antv/smart-color

A JavaScript library for color computation.

Features

  • Palette Generation: Generate categorical or discrete scale palette based on color scheme.
  • 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

$ npm install @antv/smart-color

🔨 Getting Started

  • Palette Generation
import { paletteGeneration } from '@antv/smart-color';

paletteGeneration("monochromatic", {
  color: {
    model: "rgb",
    value: { r: 91, g: 143, b: 249 },
  },
  count: 7,
  tendency: "shade"
});
auto generated palette
  • Palette Optimization
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: palette before optimization
After: palette after optimization
  • Color Simulation
import { colorSimulation } from '@antv/smart-color';

const color = {
  model: "rgb",
  value: { r: 91, g: 143, b: 249 },
}
colorSimulation(color, "achromatomaly");
color simulation result

🔗 Links

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @antv/smart-color

Weekly Downloads

559

Version

0.2.1

License

MIT

Unpacked Size

1.04 MB

Total Files

317

Last publish

Collaborators

  • xuying1027
  • lvisei
  • yisi.wang
  • basketduck
  • biupiubiupiu
  • flash1
  • dreammy23
  • laixingui.lxg
  • zhangjunjie-loki
  • rainy25ghz
  • zeyuwang
  • yanxiong
  • susiwen8
  • freestyle21
  • soundquiet
  • elaine.q.10
  • sturuby
  • sakuya223
  • serializedowen
  • xdzhao
  • yangzhanmei
  • wjgogogo
  • leungwensen
  • dori
  • iaaron
  • yard
  • simaq
  • dxq613
  • intchous
  • susan_ann
  • jinke.li
  • lzxue
  • army8735
  • atool
  • baizn
  • dengfuping
  • neoddish
  • jeffy2012
  • zqlu
  • afc163
  • pomelo-nwu
  • kopiluwaky
  • ccnuzindex
  • panyuqi
  • bubkoo
  • zengyue
  • kasmine
  • boyu.zlj
  • l1ud0ngq1
  • newbyvector
  • winniexing
  • chenluli
  • kn9117
  • xdddst
  • semious2020
  • esora
  • nadia_liu
  • bbsqq
  • mxz96102
  • openwayne
  • pearmini
  • pddpd
  • yiqianyao
  • zhanba
  • cxxxxxn