color-fns
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.1
    453
    • latest

Version History

Package Sidebar

Install

npm i color-fns

Weekly Downloads

7,281

Version

0.1.1

License

MIT

Unpacked Size

101 kB

Total Files

105

Last publish

Collaborators

  • baianaters
  • logaretm