color-fns

Modern JavaScript color utility library.

MIT 13 个版本
安装
npm install color-fns
yarn add color-fns
pnpm add color-fns
bun add color-fns
README

Build Status codecov Codacy Badge


Modern and Modular JavaScript color utility library. inspired by date-fns.

Features

  • Written in TypeScript. 😎
  • Lightweight. 💸
  • Modular and Tree-shakable.🌳
  • Multi-Color Model Support. 🎨
  • CSS compatible output. 💨

Installation

# yarn
yarn add color-fns

# npm
npm i color-fns

OR

<script src="https://unpkg.com/color-fns"></script>

Usage

// ES2015 (ES6)
import { toRgb } from 'color-fns';

console.log(toRgb('#fff'));


// CommonJS
const { toRgb } = require('color-fns');
console.log(toRgb('#fff'));

// UMD (Script Tag)
console.log(ColorFns.toRgb('#fff'));

Available Functions

Parsing

  • parseCmyk
  • parseHex
  • parseHsl
  • parseHsv
  • parseRgb

Conversion

  • cmykToRgb
  • hexToRgb
  • hslToRgb
  • hsvToRgb
  • rgbToCmyk
  • rgbToHex
  • rgbToHsl
  • rgbToHsv
  • toCmyk
  • toHex
  • toHsl
  • toHsv
  • toRgb

Operations

  • mix

Format and Display

  • expandHexShorthand
  • formatCmyk
  • formatHex
  • formatHsl
  • formatHsv
  • formatRgb

Validation

  • isValidCmyk
  • isValidHex
  • isValidHsl
  • isValidHsv
  • isValidRgb

Querying

  • whichModel
  • constrastInfo
  • isDark

Calculations

  • relativeLuminance

Contribution

Contributions are welcomed, however make sure you read the contribution guide and the code of conduct before making any pull requests.

License

MIT

版本列表
0.1.1 2019-05-23
0.1.0 2019-05-23
0.0.10 2019-01-23
0.0.9 2019-01-13
0.0.8 2019-01-13
0.0.7 2018-07-13
0.0.6 2018-05-28
0.0.5 2018-05-28
0.0.4 2018-04-19
0.0.3 2018-04-12
0.0.2 2018-03-27
0.0.1 2018-03-13
0.0.0 2018-01-08