1. @antv/color-util
A common util collection for antv projects
@antv/color-util
Package: @antv/color-util
Created by: antvis
Last modified: Sun, 28 Apr 2024 08:58:38 GMT
Version: 2.0.6
License: ISC
Downloads: 410,473
Repository: https://github.com/antvis/util

Install

npm install @antv/color-util
yarn add @antv/color-util

color-util

antv 开发的轻量级工具方法库。

安装下载

tnpm i --save @antv/util

 // 所有的 api 是都这么引入,名字不同而已
import { gradient } from '@antv/color-util';

const grad = gradient(['red', 'blue']);
const color1 = grad(0.1);
const color2 = grad(0.2);

API 文档

目前使用到的、且推荐使用的 API 文档,不在文档内的不建议使用。

  • rgb2arr('#ffeedd') 将 rgb 转换成 16 进制的数组
  • gradient(colors) : 'Function' 渐变色计算
    • colors : 颜色的数组,例如 ['red', 'blue']
    • 返回值是一个函数,可以传入百分百,返回函数
 const grad = gradient(['red', 'blue']);
const color1 = grad(0.1);
const color2 = grad(0.2);
  • toRGB(color) : 将颜色转换成 RGB 的格式
 import { toRGB } from '@antv/color-util';
toRGB('red');
toRGB('rgb(240, 240, 233)');

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin