mediancut
v2.1.12
Published
Image reduction by Mediancut algorithm
Downloads
79
Readme
MedianCut
Demo
https://mediancut.vercel.app/
Usage
Install
<script type="text/javascript" src="https://unpkg.com/mediancut@latest"></script>
or
import MedianCut from 'mediancut';
Sample
// Get context
const ctx = document.getElementById('canvas').getContext('2d');
// Get Imagedata
const imagedata = ctx.getImageData(0, 0, CANVAS_SIZE, CANVAS_SIZE);
// Reduced to 16 colors
const medianCut = new MedianCut(imagedata);
const reducedImageData = medianCut.reduce(16);
// Draw
ctx.putImageData(reducedImageData, 0, 0, 0, 0, CANVAS_SIZE, CANVAS_SIZE);
Development
Installing
# Install npm packages
npm i
Running
# Watch JS & CSS
npm run watch
# Up Server
npm run server