Round image corners

This commit is contained in:
Dragon Fire
2024-04-21 14:34:50 -04:00
parent 2dfc23f8fa
commit 73f220ec80
+17 -1
View File
@@ -85,7 +85,23 @@ module.exports = class TweetCommand extends Command {
imageHeight = imageData.height * imageHeightRatio;
canvas.height += imageHeight + 15;
ctx.fillRect(0, base1.height, canvas.width, linesLen + imageHeight + 15);
ctx.drawImage(imageData, 17, base1.height + linesLen, 740, imageHeight);
const x = 17;
const y = base1.height + linesLen;
const imageWidth = 740;
const radius = 10;
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.lineTo(x + imageWidth - radius, y);
ctx.quadraticCurveTo(x + imageWidth, y, x + imageWidth, y + radius);
ctx.lineTo(x + imageWidth, y + imageHeight - radius);
ctx.quadraticCurveTo(x + imageWidth, y + imageHeight, x + imageWidth - radius, y + imageHeight);
ctx.lineTo(x + radius, y + imageHeight);
ctx.quadraticCurveTo(x, y + imageHeight, x, y + imageHeight - radius);
ctx.lineTo(x, y + radius);
ctx.quadraticCurveTo(x, y, x + radius, y);
ctx.closePath();
ctx.clip();
ctx.drawImage(imageData, x, y, imageWidth, imageHeight);
}
const likes = randomRange(Math.ceil(userData.followers * 0.0015), Math.ceil(userData.followers * 0.002));
const retweets = randomRange(Math.ceil(userData.followers * 0.00015), Math.ceil(userData.followers * 0.0002));