Coder Social home page Coder Social logo

color-palette's Introduction

color-palette

Color Utils for UI Library

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

Usage

npm i @gerainlot/color-palette
import { generate, presetColor } from "@gerainlot/color-palette";
console.log(generate("#123456"));
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

color-palette's People

Contributors

gerainlotzs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.