https://github.com/qq15725/modern-palette
🎨 Generate and use color palette through images or color data, consistent with ffmpeg.
https://github.com/qq15725/modern-palette
color-dithering color-quantization ffmpeg palette palettegen paletteuse
Last synced: 18 days ago
JSON representation
🎨 Generate and use color palette through images or color data, consistent with ffmpeg.
- Host: GitHub
- URL: https://github.com/qq15725/modern-palette
- Owner: qq15725
- License: mit
- Created: 2023-05-06T07:01:34.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-21T14:01:28.000Z (4 months ago)
- Last Synced: 2025-04-07T01:03:44.583Z (21 days ago)
- Topics: color-dithering, color-quantization, ffmpeg, palette, palettegen, paletteuse
- Language: TypeScript
- Homepage: https://modern-palette.vercel.app
- Size: 408 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
modern-palette
## 📦 Install
```sh
npm i modern-palette
```## 🦄 Usage
```ts
import { Palette } from 'modern-palette'const palette = new Palette({
maxColors: 256,
// (string | number[] | number[][] | CanvasImageSource | BufferSource)[]
samples: [document.querySelector('img'), [[255, 0, 0], [255, 0, 0]]],
})palette.addSample('/example.png')
// Generate palette colors data
palette.generate().then(colors => {
console.log(colors)// Find the nearest color on the palette
const nearestColor = palette.match('#ffffff')
// palette.match([255, 255, 255])console.log(nearestColor)
})
```## Options
See the [options.ts](src/options.ts)
## Palette
See the [Palette.ts](src/Palette.ts)