mirror of
https://github.com/1disk/edp445.git
synced 2024-08-14 22:47:02 +00:00
Changed alot of things.
This commit is contained in:
parent
a5a0523e5a
commit
3513d5390c
2016 changed files with 336930 additions and 9 deletions
50
node_modules/canvacord/libs/Trigger.js
generated
vendored
Normal file
50
node_modules/canvacord/libs/Trigger.js
generated
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
const Canvas = require("@napi-rs/canvas");
|
||||
const { GifEncoder } = require("@skyra/gifenc");
|
||||
|
||||
module.exports = async (image, TRIGGERED) => {
|
||||
const base = await Canvas.loadImage(TRIGGERED);
|
||||
const img = await Canvas.loadImage(image);
|
||||
const GIF = new GifEncoder(256, 310);
|
||||
const stream = GIF.createReadStream();
|
||||
GIF.start();
|
||||
GIF.setRepeat(0);
|
||||
GIF.setDelay(15);
|
||||
const canvas = Canvas.createCanvas(256, 310);
|
||||
const ctx = canvas.getContext("2d");
|
||||
const BR = 30;
|
||||
const LR = 20;
|
||||
let i = 0;
|
||||
while (i < 9) {
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
ctx.drawImage(
|
||||
img,
|
||||
Math.floor(Math.random() * BR) - BR,
|
||||
Math.floor(Math.random() * BR) - BR,
|
||||
256 + BR,
|
||||
310 - 54 + BR
|
||||
);
|
||||
ctx.drawImage(
|
||||
base,
|
||||
Math.floor(Math.random() * LR) - LR,
|
||||
310 - 54 + Math.floor(Math.random() * LR) - LR,
|
||||
256 + LR,
|
||||
54 + LR
|
||||
);
|
||||
// ctx.fillStyle = "#FF000011";
|
||||
// ctx.fillRect(0, 0, 256, 310);
|
||||
GIF.addFrame(ctx);
|
||||
i++;
|
||||
}
|
||||
GIF.finish();
|
||||
return streamToBuffer(stream);
|
||||
};
|
||||
|
||||
function streamToBuffer(stream) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const data = [];
|
||||
|
||||
stream.on("data", c => data.push(c));
|
||||
stream.on("end", () => resolve(Buffer.concat(data)));
|
||||
stream.on("error", reject);
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue