LivingDead NFT Project

This commit is contained in:
2022-01-10 22:49:39 +01:00
commit da22559503
64 changed files with 3234 additions and 0 deletions

38
modules/HashlipsGiffer.js Normal file
View File

@@ -0,0 +1,38 @@
const GifEncoder = require("gif-encoder-2");
const { writeFile } = require("fs");
class HashLipsGiffer {
constructor(_canvas, _ctx, _fileName, _repeat, _quality, _delay) {
this.canvas = _canvas;
this.ctx = _ctx;
this.fileName = _fileName;
this.repeat = _repeat;
this.quality = _quality;
this.delay = _delay;
this.initGifEncoder();
}
initGifEncoder = () => {
this.gifEncoder = new GifEncoder(this.canvas.width, this.canvas.height);
this.gifEncoder.setQuality(this.quality);
this.gifEncoder.setRepeat(this.repeat);
this.gifEncoder.setDelay(this.delay);
};
start = () => {
this.gifEncoder.start();
};
add = () => {
this.gifEncoder.addFrame(this.ctx);
};
stop = () => {
this.gifEncoder.finish();
const buffer = this.gifEncoder.out.getData();
writeFile(this.fileName, buffer, (error) => {});
console.log(`Created gif at ${this.fileName}`);
};
}
module.exports = HashLipsGiffer;