JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q44691F
  • License MIT

颜色辅助生成器

Package Exports

  • @fly-vue/color
  • @fly-vue/color/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@fly-vue/color) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@fly-vue/Color

根据给定颜色通过算法生成指定包含十个颜色的梯度色板,也可生成暗色模式下包含十个颜色的色板。

安装

npm i @fly-vue/color
import { generate, presetColor } from '@fly-vue/color';

console.log(generate('#FF0000',{ index: 1}));

console.log(presetColor);
// {
//   red: {...},
//   orangered: {...},
//   orange: {...},
//   gold: {...},
//   yellow: {...},
//   lime: {...},
//   green: {...},
//   cyan: {...},
//   blue: {...},
//   arcoblue: {...},
//   purple: {...},
//   pinkpurple: {...},
//   magenta: {...},
//   gray: {...}
// }

API

generate(color: string, options: Object);

options.index {number | 1-10}

生成 10 个梯度色中的第几个颜色。

options.list {boolean}

生成包含十个颜色的梯度颜色数组。

options.dark

生成暗色色板的颜色。

options.format {'hex' | 'rgb' | 'hsl'}

生成颜色的格式。

getPresetColors {Function}

包含了预设的 14 组颜色,包括一组中性灰。

  • red
  • orangered
  • orange
  • gold
  • yellow
  • lime
  • green
  • cyan
  • blue
  • arcoblue
  • purple
  • pinkpurple
  • magenta
  • gray
const { red } = getPresetColors();

console.log(red.light);
console.log(red.dark);
console.log(red.primary);

getRgbStr(color: string)

获得指定颜色的三通道 r, g, b 字符串。

getRgbStr('#F53F3F') // 245,63,63