1.0.5 • Published 2 years ago

multidither v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

This is a simple dither that you can extend with your own algorithms.

Installation

npm i multidither

Example

const { ColorPalette, FloydSteinbergDither } = require("multidither");
const Jimp = require("jimp");

Jimp.read("./file.png", (err, img) => {
  if (err) throw err;

  let dither = new FloydSteinbergDither(
    img,
    new ColorPalette([
      "#000000",
      "#ffffff",
      "#ff0000",
      "#00ff00",
      "#0000ff",
      "#ffff00",
      "#ff00ff",
      "#00ffff",
    ])
  );

  dither.dither("./out.png");
});

Docs

new FloydSteinbergDither(Jimp image, ColorPalette palette)


Dither.dither(string outputPath, bool shouldSave)

new ColorPalette(string[]| {r:number, g:number,b:number,a:number}[] colors) // hex array or grb / grba array

//Palette.nc = https://www.npmjs.com/package/nearest-rgba

making own dither algorithms

const { BaseDither } = require("multidither");
class MyDither extends BaseDither {
  constructor(image, palette) {
    super(image, palette);
  }

  dither(path, write = true) {
    // gets called when a dither process is started. this also calls onPixel
  }
  onPixel(x, y) {
    // gets called for every pixel at position x, y
  }
}

Additional info

  • I made that package intirely by myself exept the jimp package
1.0.2

2 years ago

1.0.1

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.0

2 years ago