Skip to content

Latest commit

 

History

History
60 lines (42 loc) · 2.42 KB

README.md

File metadata and controls

60 lines (42 loc) · 2.42 KB

Colorus.js

NPM TypeScript GitHub stars

A versatile and powerful color manipulation library for JavaScript.

Features

  • Intuitive API: Work with colors effortlessly using a simple and expressive function-based API.
  • Multiple Color Models: Supports various color models, including RGB, HSL, HSV, and CMYK.
  • Flexible Input/Output: Accepts color inputs in different formats (hex, rgb, hsl, etc.) and provides various output options.
  • Color Conversions: Easily convert between different color models and formats.
  • Color Adjustments: Perform common color adjustments like lightening, darkening, saturating, desaturating, and more.
  • Accessibility: Calculate relative luminance and contrast ratios for improved accessibility.
  • Extensible: Extend the core functionality with custom plugins.
  • TypeScript Support: Provides full TypeScript support for enhanced type safety and developer experience.

Usage

import { dye } from "colorus-js"

const color = dye("#ff0000") // Create a color from a hex code

console.log(color.rgb) // Output: { r: 255, g: 0, b: 0, a: 1 }
console.log(color.toHsl()) // Output: hsl(0, 100%, 50%)

const lighterColor = color.lighten(0.2) // Lighten the color by 20%
console.log(lighterColor.toHex()) // Output: #ff6666

Plugins

Extend the dye function with custom methods using plugins.

const colorWithPlugin = dye("#0000ff", {
  plugins: {
    isBlue() {
      return this.rgb.b > 200
    }
  }
})

console.log(colorWithPlugin.isBlue()) // Output: true

For more information see Working with Plugins Guide.

Contributing

Contributions are welcome! Please read the Contributing Guide.

Leave a star and help spread the hues! 🎨⭐