@mahanunu/color-utils
v1.0.0
Published
Librairie utilitaire JS/TS pour manipuler les couleurs (HEX ↔ RGB, darken, lighten, invert)
Maintainers
Readme
🎨 color-utils
color-utils est une librairie JavaScript/TypeScript simple et légère pour manipuler facilement les couleurs au format HEX et RGB.
📦 Installation
npm install color-utilsOu en local pour test :
npm install ./chemin/vers/color-utils
🚀 Utilisation
import {
hexToRgb,
rgbToHex,
invertColor,
darken,
lighten,
} from 'color-utils';
console.log(hexToRgb('#ffcc00')); // [255, 204, 0]
console.log(rgbToHex(255, 204, 0)); // '#ffcc00'
console.log(invertColor('#000000')); // '#ffffff'
console.log(darken('#ffcc00', 30)); // '#e6b300'
console.log(lighten('#ffcc00', 30)); // '#ffff1e'🧩 API
hexToRgb(hex: string): [number, number, number]
Convertit un code hexadécimal en tableau RGB
rgbToHex(r: number, g: number, b: number): string
Convertit des valeurs RGB en hexadécimal
invertColor(hex: string): string
Retourne la couleur opposée (inversée)
darken(hex: string, amount: number): string
Assombrit une couleur en diminuant ses canaux RGB
lighten(hex: string, amount: number): string
Éclaircit une couleur en augmentant ses canaux RGB
🧪 Tests
npm run testTesté avec Vitest
🧼 Lint & Format
npm run lint # Vérifie les erreurs avec ESLint
npm run format # Reformate automatiquement le code avec Prettier📝 Licence
Distribué sous licence MIT © 2025 Mahalia Pires
Voir le fichier LICENSE
