canvacord
Advanced tools
Comparing version 5.3.0 to 5.4.0-dev.0
10
index.js
@@ -1,2 +0,2 @@ | ||
// Created and maintained by Snowflake Studio ❄ | ||
// Created and maintained by DevAndromeda | ||
@@ -7,5 +7,3 @@ const Canvacord = require("./src/Canvacord"); | ||
try { | ||
setTimeout(() => { | ||
Canvacord.registerFonts(); | ||
}); | ||
Canvacord.registerFonts(); | ||
} catch(e) {} | ||
@@ -37,3 +35,3 @@ | ||
Util: require("./src/Util"), | ||
Assets: require("@canvacord/assets"), | ||
Assets: require("./src/Assets"), | ||
MSX: { | ||
@@ -50,4 +48,4 @@ Brightness: require("./libs/Brightness"), | ||
write: Canvacord.write, | ||
author: "Snowflake Studio ❄", | ||
author: "DevAndromeda", | ||
version: require("./package.json").version | ||
}; |
@@ -1,2 +0,2 @@ | ||
const Canvas = require("canvas"); | ||
const Canvas = require("@napi-rs/canvas"); | ||
@@ -19,3 +19,3 @@ module.exports = async (img, amount) => { | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
}; |
@@ -1,2 +0,2 @@ | ||
const Canvas = require("canvas"); | ||
const Canvas = require("@napi-rs/canvas"); | ||
const convolute = require("../plugins/convolute"); | ||
@@ -15,3 +15,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
}; |
@@ -1,2 +0,2 @@ | ||
const Canvas = require("canvas"); | ||
const Canvas = require("@napi-rs/canvas"); | ||
@@ -19,3 +19,3 @@ module.exports = async (img, amount) => { | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
}; |
@@ -1,2 +0,2 @@ | ||
const Canvas = require("canvas"); | ||
const Canvas = require("@napi-rs/canvas"); | ||
@@ -20,3 +20,3 @@ module.exports = async (img) => { | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
}; |
@@ -1,2 +0,2 @@ | ||
const Canvas = require("canvas"); | ||
const Canvas = require("@napi-rs/canvas"); | ||
@@ -20,3 +20,3 @@ module.exports = async (img) => { | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
}; |
@@ -1,2 +0,2 @@ | ||
const Canvas = require("canvas"); | ||
const Canvas = require("@napi-rs/canvas"); | ||
@@ -19,3 +19,3 @@ module.exports = async (img) => { | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} |
@@ -1,2 +0,2 @@ | ||
const Canvas = require("canvas"); | ||
const Canvas = require("@napi-rs/canvas"); | ||
@@ -21,3 +21,3 @@ module.exports = async (img, amount = 50) => { | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
}; |
@@ -1,3 +0,3 @@ | ||
const Canvas = require("canvas"); | ||
const GIFEncoder = require("gifencoder"); | ||
const Canvas = require("@napi-rs/canvas"); | ||
const { GifEncoder } = require("@skyra/gifenc"); | ||
@@ -7,3 +7,4 @@ module.exports = async (image, TRIGGERED) => { | ||
const img = await Canvas.loadImage(image); | ||
const GIF = new GIFEncoder(256, 310); | ||
const GIF = new GifEncoder(256, 310); | ||
const stream = GIF.createReadStream(); | ||
GIF.start(); | ||
@@ -39,3 +40,13 @@ GIF.setRepeat(0); | ||
GIF.finish(); | ||
return GIF.out.getData(); | ||
}; | ||
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); | ||
}) | ||
} |
{ | ||
"name": "canvacord", | ||
"version": "5.3.0", | ||
"version": "5.4.0-dev.0", | ||
"description": "Powerful image manipulation package for beginners.", | ||
"main": "index.js", | ||
"types": "typings/index.d.ts", | ||
"bin": "./bin/canvacord.js", | ||
"files": [ | ||
"bin", | ||
"libs", | ||
@@ -17,7 +19,8 @@ "plugins", | ||
"docs:test": "docgen --source src --custom docs/index.yml", | ||
"test": "cd test && node ." | ||
"test": "cd test && node .", | ||
"postinstall": "node scripts/postinstall.mjs" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/DevSnowflake/Canvacord.git" | ||
"url": "git+https://github.com/DevAndromeda/Canvacord.git" | ||
}, | ||
@@ -41,3 +44,3 @@ "keywords": [ | ||
], | ||
"author": "Snowflake107", | ||
"author": "DevAndromeda", | ||
"funding": { | ||
@@ -49,19 +52,18 @@ "type": "individual", | ||
"bugs": { | ||
"url": "https://github.com/DevSnowflake/Canvacord/issues" | ||
"url": "https://github.com/DevAndromeda/Canvacord/issues" | ||
}, | ||
"homepage": "https://canvacord.js.org", | ||
"dependencies": { | ||
"@canvacord/assets": "^2.0.5", | ||
"@canvacord/emoji-parser": "^1.0.1", | ||
"canvas": "^2.8.0", | ||
"gifencoder": "^2.0.1", | ||
"@napi-rs/canvas": "^0.1.25", | ||
"@skyra/gifenc": "^1.0.0", | ||
"chalk": "^5.0.1", | ||
"moment": "^2.29.1", | ||
"moment-duration-format": "^2.3.2" | ||
"moment-duration-format": "^2.3.2", | ||
"node-fetch": "2.6.6" | ||
}, | ||
"devDependencies": { | ||
"@discordjs/docgen": "discordjs/docgen", | ||
"@types/node": "^16.4.7", | ||
"captcha-canvas": "^2.3.1", | ||
"discord-canvas": "github:snowflake107/discord-canvas" | ||
"@discordjs/docgen": "^0.11.1", | ||
"@types/node": "^16.4.7" | ||
} | ||
} |
@@ -18,3 +18,3 @@ [![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://vshymanskyy.github.io/StandWithUkraine) | ||
- More than **50 methods**...? Yay! 🎉 | ||
- Built on node-canvas and no bullsh*t involved 🔥 | ||
- Built on **[@napi-rs/canvas](https://npm.im/@napi-rs/canvas)** 🔥 | ||
- Object oriented 💻 | ||
@@ -28,3 +28,3 @@ - Beginner friendly 🤓 | ||
# Join our Discord server | ||
**[https://discord.gg/2SUybzb](https://discord.gg/2SUybzb)** | ||
**[https://discord.gg/CR8JxrxSwr](https://discord.gg/CR8JxrxSwr)** | ||
@@ -57,3 +57,3 @@ # Examples | ||
### Preview | ||
![RankCard](https://raw.githubusercontent.com/Snowflake107/canvacord/v5/test/images/RankCard.png) | ||
![RankCard](https://raw.githubusercontent.com/DevAndromeda/canvacord/v5/test/images/RankCard.png) | ||
@@ -60,0 +60,0 @@ ## Other Examples |
@@ -1,3 +0,57 @@ | ||
const assets = require("@canvacord/assets"); | ||
const fs = require("fs"); | ||
module.exports = assets; | ||
const ASSETS_DIR = "CANVACORD_ASSETS" in process.env ? process.env.CANVACORD_ASSETS : `${__dirname}/../assets`; | ||
let loaded = false; | ||
function loadAssets(warnIfFailed = true) { | ||
for (const asset of ["fonts", "images"]) { | ||
try { | ||
const data = fs.readdirSync(`${ASSETS_DIR}/${asset}`); | ||
data.forEach(d => { | ||
const name = d.split(".").shift(); | ||
(asset === "fonts" ? store.fonts : store.images)[name] = { | ||
name, | ||
path: `${ASSETS_DIR}/${asset}/${d}`, | ||
type: asset === "fonts" ? "FONT" : "IMAGE" | ||
}; | ||
}); | ||
} catch { | ||
if (warnIfFailed) process.emitWarning("[Canvacord] Could not load assets. Try running \"npx canvacord rebuild --force\""); | ||
} | ||
} | ||
} | ||
const ensureLoaded = () => { | ||
if (!loaded) { | ||
loadAssets(); | ||
loaded = true; | ||
} | ||
}; | ||
module.exports = { | ||
load: loadAssets, | ||
ASSETS_DIR, | ||
font: { | ||
get(name) { | ||
if (!name || typeof name !== "string") throw new TypeError("font name must be a string"); | ||
ensureLoaded(); | ||
return store.fonts[name]; | ||
}, | ||
all() { | ||
ensureLoaded(); | ||
return store.fonts; | ||
} | ||
}, | ||
image: { | ||
get(name) { | ||
if (!name || typeof name !== "string") throw new TypeError("image name must be a string"); | ||
ensureLoaded(); | ||
return store.images[name]; | ||
}, | ||
all() { | ||
ensureLoaded(); | ||
return store.images; | ||
} | ||
} | ||
}; |
@@ -11,3 +11,3 @@ const Trigger = require("../libs/Trigger"); | ||
const rect = require("../plugins/rect"); | ||
const Canvas = require("canvas"); | ||
const Canvas = require("@napi-rs/canvas"); | ||
const Darkness = require("../libs/Darkness"); | ||
@@ -184,3 +184,3 @@ const circle = require("../plugins/circle"); | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -209,3 +209,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -251,3 +251,3 @@ | ||
const ic = Util.invertColor(color); | ||
ctx.font = "bold 72px Manrope"; | ||
ctx.font = "bold 72px MANROPE_BOLD"; | ||
ctx.fillStyle = ic; | ||
@@ -272,3 +272,3 @@ ctx.fillText(color.toUpperCase(), canvas.width / 3, canvas.height / 2); | ||
circle(ctx, canvas.width, canvas.height); | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -314,3 +314,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -333,3 +333,3 @@ | ||
ctx.drawImage(img, 0, 0, canvas.width, canvas.height); | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -355,3 +355,3 @@ | ||
ctx.drawImage(avatar, 150, 25, 200, 200); | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -377,3 +377,3 @@ | ||
ctx.drawImage(avatar, 225, 5, 140, 140); | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -387,50 +387,15 @@ | ||
static async registerFonts(fontArray = []) { | ||
if (!Canvacord.assets.font.loaded) await Canvacord.assets.font.load(); | ||
if (!Canvacord.assets.image.loaded) await Canvacord.assets.image.load(); | ||
if (!fontArray.length) { | ||
await Canvacord.__wait(); | ||
// default fonts | ||
Canvas.registerFont(Canvacord.assets.font.get("MANROPE_BOLD"), { | ||
family: "Manrope", | ||
weight: "bold", | ||
style: "normal" | ||
}); | ||
Canvas.registerFont(Canvacord.assets.font.get("MANROPE_REGULAR"), { | ||
family: "Manrope", | ||
weight: "regular", | ||
style: "normal" | ||
}); | ||
Canvas.registerFont(Canvacord.assets.font.get("WHITNEY_MEDIUM"), { | ||
family: "Whitney", | ||
weight: "regular", | ||
style: "normal" | ||
}); | ||
Canvas.registerFont(Canvacord.assets.font.get("WHITNEY_BOOK"), { | ||
family: "Whitney", | ||
weight: "bold", | ||
style: "normal" | ||
}); | ||
Canvas.registerFont(Canvacord.assets.font.get("ROBOTO_LIGHT"), { | ||
family: "Roboto", | ||
weight: "light", | ||
style: "normal" | ||
}); | ||
Canvas.registerFont(Canvacord.assets.font.get("ROBOTO_REGULAR"), { | ||
family: "Roboto", | ||
weight: "regular", | ||
style: "normal" | ||
}); | ||
Canvas.GlobalFonts.loadFontsFromDir(`${Canvacord.assets.ASSETS_DIR}/fonts`) | ||
Canvas.GlobalFonts.registerFromPath(Canvacord.assets.font.get("MANROPE_BOLD"), "MANROPE_BOLD"); | ||
Canvas.GlobalFonts.registerFromPath(Canvacord.assets.font.get("MANROPE_REGULAR"), "MANROPE_REGULAR"); | ||
Canvas.GlobalFonts.registerFromPath(Canvacord.assets.font.get("WHITNEY_MEDIUM"), "WHITNEY_MEDIUM"); | ||
Canvas.GlobalFonts.registerFromPath(Canvacord.assets.font.get("WHITNEY_BOOK"), "WHITNEY_BOOK"); | ||
Canvas.GlobalFonts.registerFromPath(Canvacord.assets.font.get("ROBOTO_LIGHT"), "ROBOTO_LIGHT"); | ||
Canvas.GlobalFonts.registerFromPath(Canvacord.assets.font.get("ROBOTO_REGULAR"), "ROBOTO_REGULAR"); | ||
} else { | ||
fontArray.forEach(font => { | ||
Canvas.registerFont(font.path, font.face); | ||
Canvas.GlobalFonts.registerFromPath(font.path, font.name || font.face?.family); | ||
}); | ||
} | ||
return; | ||
} | ||
@@ -456,3 +421,3 @@ | ||
ctx.drawImage(avatar, 350, 70, 220, 220); | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -476,3 +441,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -496,3 +461,3 @@ | ||
ctx.drawImage(layer, 0, 0, 632, 357); | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -514,3 +479,3 @@ | ||
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height); | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -532,3 +497,3 @@ | ||
ctx.drawImage(img, 63, 110, 90, 90); | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -552,3 +517,3 @@ | ||
ctx.drawImage(img, 309, 0, 309, 309); | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -573,3 +538,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -594,3 +559,3 @@ | ||
} | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -614,3 +579,3 @@ | ||
ctx.drawImage(layer, 0, 0, 425, 404); | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -642,3 +607,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -663,3 +628,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -685,3 +650,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -712,3 +677,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -734,3 +699,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -891,3 +856,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -937,3 +902,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -992,3 +957,3 @@ | ||
} | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -1006,14 +971,3 @@ | ||
let badge = await Canvas.loadImage(Canvacord.assets.image.get("BOTBADGE")); | ||
Canvas.registerFont(Canvacord.assets.font.get("WHITNEY_MEDIUM"), { | ||
family: "Whitney", | ||
weight: "regular", | ||
style: "normal" | ||
}); | ||
Canvas.registerFont(Canvacord.assets.font.get("MANROPE_REGULAR"), { | ||
family: "Manrope", | ||
weight: "regular", | ||
style: "normal" | ||
}); | ||
const canvas = Canvas.createCanvas(1500, 300); | ||
@@ -1028,3 +982,3 @@ | ||
ctx.font = "40px Manrope"; | ||
ctx.font = "40px MANROPE_REGULAR"; | ||
ctx.fillStyle = "#FFFFFF"; | ||
@@ -1034,3 +988,3 @@ ctx.textAlign = "start"; | ||
ctx.font = "50px Whitney"; | ||
ctx.font = "50px WHITNEY_MEDIUM"; | ||
ctx.fillStyle = "#FFFFFF"; | ||
@@ -1040,3 +994,3 @@ ctx.textAlign = "start"; | ||
ctx.font = "40px Whitney"; | ||
ctx.font = "40px WHITNEY_MEDIUM"; | ||
ctx.fillStyle = "#7D7D7D"; | ||
@@ -1046,3 +1000,3 @@ ctx.textAlign = "start"; | ||
ctx.font = "20px Manrope"; | ||
ctx.font = "20px MANROPE_REGULAR"; | ||
ctx.fillStyle = "#7D7D7D"; | ||
@@ -1052,3 +1006,3 @@ ctx.textAlign = "start"; | ||
ctx.font = "20px Manrope"; | ||
ctx.font = "20px MANROPE_REGULAR"; | ||
ctx.fillStyle = "#2785C7"; | ||
@@ -1058,3 +1012,3 @@ ctx.textAlign = "start"; | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -1080,14 +1034,2 @@ | ||
Canvas.registerFont(Canvacord.assets.font.get("WHITNEY_MEDIUM"), { | ||
family: "Whitney", | ||
weight: "regular", | ||
style: "normal" | ||
}); | ||
Canvas.registerFont(Canvacord.assets.font.get("MANROPE_REGULAR"), { | ||
family: "Manrope", | ||
weight: "regular", | ||
style: "normal" | ||
}); | ||
const canvas = Canvas.createCanvas(1500, 300); | ||
@@ -1101,3 +1043,3 @@ | ||
ctx.font = "40px Manrope"; | ||
ctx.font = "40px MANROPE_REGULAR"; | ||
ctx.fillStyle = "#FFFFFF"; | ||
@@ -1107,3 +1049,3 @@ ctx.textAlign = "start"; | ||
ctx.font = "50px Whitney"; | ||
ctx.font = "50px WHITNEY_MEDIUM"; | ||
ctx.fillStyle = typeof options.color == "string" ? options.color : "#FFFFFF"; | ||
@@ -1113,3 +1055,3 @@ ctx.textAlign = "start"; | ||
ctx.font = "40px Whitney"; | ||
ctx.font = "40px WHITNEY_MEDIUM"; | ||
ctx.fillStyle = "#7D7D7D"; | ||
@@ -1119,3 +1061,3 @@ ctx.textAlign = "start"; | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -1156,3 +1098,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -1177,3 +1119,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -1198,3 +1140,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -1245,3 +1187,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -1266,3 +1208,3 @@ | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -1298,6 +1240,6 @@ | ||
ctx.fillStyle = "#FFFFFF"; | ||
ctx.font = `bold ${size / 4}px Whitney`; | ||
ctx.font = `bold ${size / 4}px WHITNEY_MEDIUM`; | ||
await Util.renderEmoji(ctx, str, canvas.width / 4, canvas.height / 1.7); | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -1346,14 +1288,2 @@ | ||
Canvas.registerFont(Canvacord.assets.font.get("WHITNEY_MEDIUM"), { | ||
family: "Whitney", | ||
weight: "regular", | ||
style: "normal" | ||
}); | ||
Canvas.registerFont(Canvacord.assets.font.get("MANROPE_REGULAR"), { | ||
family: "Manrope", | ||
weight: "regular", | ||
style: "normal" | ||
}); | ||
const canvas = Canvas.createCanvas(1300, 250); | ||
@@ -1368,7 +1298,7 @@ const ctx = canvas.getContext("2d"); | ||
ctx.font = "38px Manrope"; | ||
ctx.font = "38px MANROPE_REGULAR"; | ||
await Util.renderEmoji(ctx, Util.shorten(replyText, 32), 186, 200); | ||
ctx.font = "38px Whitney"; | ||
ctx.font = "38px WHITNEY_MEDIUM"; | ||
ctx.fillStyle = Util.formatHex(hex1, "#FFFFFF"); | ||
@@ -1379,3 +1309,3 @@ ctx.fillText(user1, 185, 147); | ||
ctx.fillStyle = "#d1d1d1"; | ||
ctx.font = "38px Manrope"; | ||
ctx.font = "38px MANROPE_REGULAR"; | ||
@@ -1387,3 +1317,3 @@ ctx.fillText(" replied to ", 165 + usernameWidth + 20, 147); | ||
ctx.fillStyle = Util.formatHex(hex2, "#FFFFFF"); | ||
ctx.font = "38px Whitney"; | ||
ctx.font = "38px WHITNEY_MEDIUM"; | ||
ctx.fillText(user2, 165 + usernameWidth + repliedWidth + 20, 167 - 20); | ||
@@ -1393,3 +1323,3 @@ | ||
ctx.font = "26px Whitney"; | ||
ctx.font = "26px WHITNEY_MEDIUM"; | ||
ctx.fillStyle = "#7a7c80"; | ||
@@ -1400,3 +1330,3 @@ const time = Util.discordTime(); | ||
ctx.font = "29px Whitney"; | ||
ctx.font = "29px WHITNEY_MEDIUM"; | ||
ctx.globalAlpha = 0.7; | ||
@@ -1446,3 +1376,3 @@ ctx.fillStyle = "#d1d1d1"; | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -1452,3 +1382,2 @@ | ||
* Canvacord assets | ||
* @type {CanvacordAssets} | ||
* @private | ||
@@ -1455,0 +1384,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
const Canvas = require("canvas"); | ||
const Canvas = require("@napi-rs/canvas"); | ||
const Util = require("./Util"); | ||
@@ -172,23 +172,6 @@ const assets = require("./Assets"); | ||
registerFonts(fontArray = []) { | ||
if (!fontArray.length) { | ||
setTimeout(() => { | ||
// default fonts | ||
Canvas.registerFont(assets.font.get("MANROPE_BOLD"), { | ||
family: "Manrope", | ||
weight: "bold", | ||
style: "normal" | ||
}); | ||
fontArray.forEach(font => { | ||
Canvas.GlobalFonts.registerFromPath(font.path, font.name || font.face?.name); | ||
}); | ||
Canvas.registerFont(assets.font.get("MANROPE_REGULAR"), { | ||
family: "Manrope", | ||
weight: "regular", | ||
style: "normal" | ||
}); | ||
}, 250); | ||
} else { | ||
fontArray.forEach(font => { | ||
Canvas.registerFont(font.path, font.face); | ||
}); | ||
} | ||
return this; | ||
@@ -476,7 +459,7 @@ } | ||
* @param {object} ops Fonts | ||
* @param {string} [ops.fontX="Manrope"] Bold font family | ||
* @param {string} [ops.fontY="Manrope"] Regular font family | ||
* @param {string} [ops.fontX="MANROPE_BOLD"] Bold font family | ||
* @param {string} [ops.fontY="MANROPE_REGULAR"] Regular font family | ||
* @returns {Promise<Buffer>} | ||
*/ | ||
async build(ops = { fontX: "Manrope", fontY: "Manrope" }) { | ||
async build(ops = { fontX: "MANROPE_BOLD", fontY: "MANROPE_BOLD" }) { | ||
if (typeof this.data.currentXP.data !== "number") throw new Error(`Expected currentXP to be a number, received ${typeof this.data.currentXP.data}!`); | ||
@@ -634,3 +617,3 @@ if (typeof this.data.requiredXP.data !== "number") throw new Error(`Expected requiredXP to be a number, received ${typeof this.data.requiredXP.data}!`); | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -637,0 +620,0 @@ |
@@ -1,2 +0,2 @@ | ||
const Canvas = require("canvas"); | ||
const Canvas = require("@napi-rs/canvas"); | ||
const Util = require("./Util"); | ||
@@ -93,29 +93,5 @@ const assets = require("./Assets"); | ||
}; | ||
this.__registerFonts(); | ||
} | ||
/** | ||
* Register fonts | ||
* @returns {void} | ||
* @ignore | ||
* @private | ||
*/ | ||
__registerFonts() { | ||
setTimeout(() => { | ||
Canvas.registerFont(assets.font.get("MANROPE_REGULAR"), { | ||
family: "Manrope", | ||
weight: "regular", | ||
style: "normal" | ||
}); | ||
Canvas.registerFont(assets.font.get("MANROPE_BOLD"), { | ||
family: "Manrope", | ||
weight: "bold", | ||
style: "normal" | ||
}); | ||
}, 250); | ||
} | ||
/** | ||
* Set progressbar details | ||
@@ -269,3 +245,3 @@ * @param {"TRACK"|"BAR"} type Progressbar type | ||
ctx.fillStyle = "#FFFFFF"; | ||
ctx.font = "bold 20px Manrope"; | ||
ctx.font = "bold 20px MANROPE_BOLD"; | ||
await Util.renderEmoji(ctx, Util.shorten(this.title, 30), 170, 40); | ||
@@ -275,3 +251,3 @@ | ||
ctx.fillStyle = "#F1F1F1"; | ||
ctx.font = "14px Manrope"; | ||
ctx.font = "14px MANROPE_REGULAR"; | ||
await Util.renderEmoji(ctx, `by ${Util.shorten(this.artist, 40)}`, 170, 70); | ||
@@ -282,3 +258,3 @@ | ||
ctx.fillStyle = "#F1F1F1"; | ||
ctx.font = "14px Manrope"; | ||
ctx.font = "14px MANROPE_REGULAR"; | ||
await Util.renderEmoji(ctx, `on ${Util.shorten(this.album, 40)}`, 170, 90); | ||
@@ -289,3 +265,3 @@ } | ||
ctx.fillStyle = "#B3B3B3"; | ||
ctx.font = "14px Manrope"; | ||
ctx.font = "14px MANROPE_REGULAR"; | ||
await Util.renderEmoji(ctx, ending, 430, 130); | ||
@@ -295,3 +271,3 @@ | ||
ctx.fillStyle = "#B3B3B3"; | ||
ctx.font = "14px Manrope"; | ||
ctx.font = "14px MANROPE_REGULAR"; | ||
await Util.renderEmoji(ctx, progressF, 170, 130); | ||
@@ -309,3 +285,3 @@ | ||
// return | ||
return canvas.toBuffer(); | ||
return canvas.encode("png"); | ||
} | ||
@@ -312,0 +288,0 @@ |
@@ -912,4 +912,4 @@ // generated by JSDOC | ||
* @param ops - <p>Fonts</p> | ||
* @param [ops.fontX = "Manrope"] - <p>Bold font family</p> | ||
* @param [ops.fontY = "Manrope"] - <p>Regular font family</p> | ||
* @param [ops.fontX = "MANROPE_BOLD"] - <p>Bold font family</p> | ||
* @param [ops.fontY = "MANROPE_REGULAR"] - <p>Regular font family</p> | ||
*/ | ||
@@ -916,0 +916,0 @@ build(ops?: { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
191712
2
29
7
3855
1
1
5
+ Added@napi-rs/canvas@^0.1.25
+ Added@skyra/gifenc@^1.0.0
+ Addedchalk@^5.0.1
+ Addednode-fetch@2.6.6
+ Added@napi-rs/canvas@0.1.65(transitive)
+ Added@napi-rs/canvas-android-arm64@0.1.65(transitive)
+ Added@napi-rs/canvas-darwin-arm64@0.1.65(transitive)
+ Added@napi-rs/canvas-darwin-x64@0.1.65(transitive)
+ Added@napi-rs/canvas-linux-arm-gnueabihf@0.1.65(transitive)
+ Added@napi-rs/canvas-linux-arm64-gnu@0.1.65(transitive)
+ Added@napi-rs/canvas-linux-arm64-musl@0.1.65(transitive)
+ Added@napi-rs/canvas-linux-riscv64-gnu@0.1.65(transitive)
+ Added@napi-rs/canvas-linux-x64-gnu@0.1.65(transitive)
+ Added@napi-rs/canvas-linux-x64-musl@0.1.65(transitive)
+ Added@napi-rs/canvas-win32-x64-msvc@0.1.65(transitive)
+ Added@skyra/gifenc@1.0.1(transitive)
+ Addedchalk@5.3.0(transitive)
+ Addednode-fetch@2.6.6(transitive)
+ Addedtslib@2.8.1(transitive)
- Removed@canvacord/assets@^2.0.5
- Removedcanvas@^2.8.0
- Removedgifencoder@^2.0.1
- Removed@canvacord/assets@2.1.0(transitive)
- Removed@mapbox/node-pre-gyp@1.0.11(transitive)
- Removedabbrev@1.1.1(transitive)
- Removedagent-base@6.0.2(transitive)
- Removedansi-regex@5.0.1(transitive)
- Removedaproba@2.0.0(transitive)
- Removedare-we-there-yet@2.0.0(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedcanvas@2.11.2(transitive)
- Removedchownr@2.0.0(transitive)
- Removedcolor-support@1.1.3(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedconsole-control-strings@1.1.0(transitive)
- Removeddebug@4.4.0(transitive)
- Removeddecompress-response@4.2.1(transitive)
- Removeddelegates@1.0.0(transitive)
- Removeddetect-libc@2.0.3(transitive)
- Removedemoji-regex@8.0.0(transitive)
- Removedfs-minipass@2.1.0(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedgauge@3.0.2(transitive)
- Removedgifencoder@2.0.1(transitive)
- Removedglob@7.2.3(transitive)
- Removedhas-unicode@2.0.1(transitive)
- Removedhttps-proxy-agent@5.0.1(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-fullwidth-code-point@3.0.0(transitive)
- Removedmake-dir@3.1.0(transitive)
- Removedmimic-response@2.1.0(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedminipass@3.3.65.0.0(transitive)
- Removedminizlib@2.1.2(transitive)
- Removedmkdirp@1.0.4(transitive)
- Removedms@2.1.3(transitive)
- Removednan@2.22.0(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removednopt@5.0.0(transitive)
- Removednpmlog@5.0.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedrimraf@3.0.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsemver@6.3.17.6.3(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedsimple-concat@1.0.1(transitive)
- Removedsimple-get@3.1.1(transitive)
- Removedstring-width@4.2.3(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedstrip-ansi@6.0.1(transitive)
- Removedtar@6.2.1(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedwide-align@1.1.5(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedyallist@4.0.0(transitive)