Skip to content

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

License

Notifications You must be signed in to change notification settings

qq15725/modern-palette

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

modern-palette

Minzip Version Downloads Issues License

📦 Install

npm i modern-palette

🦄 Usage

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

Palette

See the Palette.ts