@ptbarnum/color-tools
TypeScript icon, indicating that this package has built-in type declarations

0.0.20 • Public • Published

Color Tools

Create and modify colors

import ColorTools from 'color-tools';

const colorTools = new ColorTools({
  mode: 'light',
  themes: {
    light: {
      bg: 'rgba(232, 236, 240, 1.00)',
      fg: 'rgba(100, 0, 254, 1.00)',
    },
    dark: {
      bg: 'rgba(30, 34, 38, 1.00)',
      fg: 'rgba(60, 255, 180, 1.00)',
    },
    common: {
      red: 'rgba(255, 50, 50, 1.00)',
    },
  },
  setTheme: (newThemeMode: string) => {
    // intercept and manage theme state
  },
  toggle: (newThemeMode: string) => {
    // intercept and manage theme state
  },
});

// Get current theme
colorTools.mode; // 'light'

// Get current foreground color
colorTools.get('fg'); // 'rgba(100, 0, 254, 1.00)'

// toggle between light and dark
colorTools.toggle(); // 'dark'

// Get current theme
colorTools.mode; // 'light'

// Get current foreground color
colorTools.get('fg'); // 'rgba(60, 255, 180, 1.00)'

// Adjust alpha (opacity) of foreground color
colorTools.alpha('fg', 0.55) // 'rgba(60, 255, 180, 0.55)'

// Adjust foreground color darker
colorTools.darker('fg', 1) // 'rgba(52, 247, 172, 1)'

// Adjust foreground color lighter
colorTools.lighter('fg', 1) // 'rgba(68, 255, 188, 1)'

Readme

Keywords

Package Sidebar

Install

npm i @ptbarnum/color-tools

Weekly Downloads

0

Version

0.0.20

License

ISC

Unpacked Size

30.3 kB

Total Files

22

Last publish

Collaborators

  • ptbarnum4