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 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 ?? 13) * scale;
1120
+ const fontSize = (config.fontSize ?? 22) * scale;
1121
1121
  const position = config.position ?? "bottom-right";
1122
- const isRight = position === "bottom-right" || position === "top-right";
1123
- const isBottom = position === "bottom-right" || position === "bottom-left";
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 = 20 * scale;
1126
- const gap = 8 * scale;
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
- const startX = isRight ? width - margin - contentWidth : margin;
1134
- const centerY = isBottom ? height - margin - logoSize / 2 : margin + logoSize / 2;
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;