# modern-palette

> Generate and use color palette through images or color data, consistent with ffmpeg.

Latest version **2.0.0** (published 2024-01-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install modern-palette
pnpm add modern-palette
yarn add modern-palette
bun add modern-palette
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2024-01-10 |
| First published | 2023-05-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 56.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | wxm |
| Maintainers | wengxiangmin |
| Keywords | modern-palette, palette, color-quantization, color-dithering, ffmpeg, palettegen, paletteuse |

## Links

- npm: https://www.npmjs.com/package/modern-palette
- Repository: https://github.com/qq15725/modern-palette
- Issues: https://github.com/qq15725/modern-palette/issues
- npm.io page: https://npm.io/package/modern-palette

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2024-01-10
- 0.2.4 — 2023-05-18
- 0.2.3 — 2023-05-12
- 0.2.2 — 2023-05-12
- 0.2.1 — 2023-05-12
- 0.2.0 — 2023-05-11
- 0.1.8 — 2023-05-09
- 0.1.7 — 2023-05-09
- 0.1.6 — 2023-05-09
- 0.1.4 — 2023-05-08
- 0.1.3 — 2023-05-08
- 0.1.2 — 2023-05-08
- 0.1.1 — 2023-05-08
- 0.1.0 — 2023-05-08
- 0.0.3 — 2023-05-08
- … 2 more at https://npm.io/package/modern-palette/versions

## README

<h1 align="center">modern-palette</h1>

<p align="center">
  <a href="https://unpkg.com/modern-palette">
    <img src="https://img.shields.io/bundlephobia/minzip/modern-palette" alt="Minzip">
  </a>
  <a href="https://www.npmjs.com/package/modern-palette">
    <img src="https://img.shields.io/npm/v/modern-palette.svg" alt="Version">
  </a>
  <a href="https://www.npmjs.com/package/modern-palette">
    <img src="https://img.shields.io/npm/dm/modern-palette" alt="Downloads">
  </a>
  <a href="https://github.com/qq15725/modern-palette/issues">
    <img src="https://img.shields.io/github/issues/qq15725/modern-palette" alt="Issues">
  </a>
  <a href="https://github.com/qq15725/modern-palette/blob/main/LICENSE">
    <img src="https://img.shields.io/npm/l/modern-palette.svg" alt="License">
  </a>
</p>

## 📦 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)

---
_Source: https://npm.io/package/modern-palette · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
