@ptbarnum/color-tools
v0.0.20
Published
Color tools
Downloads
31
Readme
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)'