kira-arts 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +17 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -41
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +44 -41
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +17 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ client.on("messageCreate", async (message) => {
|
|
|
69
69
|
badgesFrame: true,
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
await message.reply({ files: [toAttachment(buffer, "profile", "png")] });
|
|
72
|
+
await message.reply({ files: [toAttachment(buffer, { name: "profile", extension: "png" })] });
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
client.login(process.env.TOKEN);
|
package/dist/index.cjs
CHANGED
|
@@ -1117,21 +1117,31 @@ async function applyWatermarkToCanvas(canvas) {
|
|
|
1117
1117
|
const margin = config.margin ?? 16;
|
|
1118
1118
|
const scale = config.scale && config.scale > 0 ? config.scale : 1;
|
|
1119
1119
|
const opacity = config.opacity != null ? Math.min(1, Math.max(0, config.opacity)) : .6;
|
|
1120
|
-
const fontSize = (config.fontSize ??
|
|
1120
|
+
const fontSize = (config.fontSize ?? 22) * scale;
|
|
1121
1121
|
const position = config.position ?? "bottom-right";
|
|
1122
|
-
const
|
|
1123
|
-
const
|
|
1122
|
+
const isLeft = position === "top-left" || position === "bottom-left" || position === "center-left";
|
|
1123
|
+
const isRight = position === "top-right" || position === "bottom-right" || position === "center-right";
|
|
1124
|
+
const isTop = position === "top-left" || position === "top-right";
|
|
1125
|
+
const isBottom = position === "bottom-left" || position === "bottom-right";
|
|
1124
1126
|
const logo = config.imageUrl ? await resolveWatermarkImage(config.imageUrl) : void 0;
|
|
1125
|
-
const logoSize =
|
|
1126
|
-
const gap =
|
|
1127
|
+
const logoSize = (config.size && config.size > 0 ? config.size : 56) * scale;
|
|
1128
|
+
const gap = 12 * scale;
|
|
1127
1129
|
let contentWidth = 0;
|
|
1128
1130
|
if (logo) contentWidth += logoSize;
|
|
1129
1131
|
if (config.text) {
|
|
1130
1132
|
ctx.font = `${fontSize}px sans-serif`;
|
|
1131
1133
|
contentWidth += (logo ? gap : 0) + ctx.measureText(config.text).width;
|
|
1132
1134
|
}
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
+
let startX;
|
|
1136
|
+
if (isRight) startX = width - margin - contentWidth;
|
|
1137
|
+
else if (isLeft) startX = margin;
|
|
1138
|
+
else startX = (width - contentWidth) / 2;
|
|
1139
|
+
let centerY;
|
|
1140
|
+
if (isBottom) centerY = height - margin - logoSize / 2;
|
|
1141
|
+
else if (isTop) centerY = margin + logoSize / 2;
|
|
1142
|
+
else centerY = height / 2;
|
|
1143
|
+
startX += config.offsetX ?? 0;
|
|
1144
|
+
centerY += config.offsetY ?? 0;
|
|
1135
1145
|
ctx.save();
|
|
1136
1146
|
ctx.globalAlpha = opacity;
|
|
1137
1147
|
let cursorX = startX;
|