mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-13 15:58:06 +02:00
Fix tweet positioning
This commit is contained in:
@@ -104,11 +104,11 @@ module.exports = class TweetCommand extends Command {
|
||||
const views = randomRange(Math.ceil(userData.followers * 10), Math.ceil(userData.followers * 30));
|
||||
ctx.drawImage(base1, 0, 0);
|
||||
const base2StartY = base1.height + linesLen + (image ? imageHeight + 15 : 0);
|
||||
ctx.drawImage(base2, 0, base2StartY);
|
||||
ctx.drawImage(base2, 0, base2StartY - 1);
|
||||
ctx.textBaseline = 'top';
|
||||
ctx.font = this.client.fonts.get('ChirpBold.ttf').toCanvasString(18);
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.fillText(userData.name, 80, 88);
|
||||
ctx.fillText(userData.name, 80, 91);
|
||||
const nameLen = ctx.measureText(userData.name).width;
|
||||
if (userData.checkType) {
|
||||
const verified = await loadImage(
|
||||
@@ -132,66 +132,66 @@ module.exports = class TweetCommand extends Command {
|
||||
}
|
||||
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(17);
|
||||
ctx.fillStyle = '#71767b';
|
||||
ctx.fillText(`@${userData.screenName}`, 80, 113);
|
||||
ctx.fillText(`@${userData.screenName}`, 80, 116);
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(23);
|
||||
await this.fillTextWithEmoji(ctx, text, 17, 160, 710, 26);
|
||||
await this.fillTextWithEmoji(ctx, text, 17, 160, 713, 26);
|
||||
ctx.fillStyle = '#71767b';
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(18);
|
||||
const time = moment().format('h:mm A ∙ MMM D, YYYY ∙');
|
||||
ctx.fillText(time, 18, base2StartY + 12);
|
||||
ctx.fillText(time, 18, base2StartY + 15);
|
||||
const timeLen = ctx.measureText(time).width;
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.font = this.client.fonts.get('Noto-Bold.ttf').toCanvasString(18);
|
||||
ctx.fillText(formatNumberK(views), 18 + timeLen + 6, base2StartY + 12);
|
||||
ctx.fillText(formatNumberK(views), 18 + timeLen + 6, base2StartY + 15);
|
||||
const viewsLen = ctx.measureText(formatNumberK(views)).width;
|
||||
ctx.fillStyle = '#71767b';
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(18);
|
||||
ctx.fillText('Views', 18 + timeLen + 6 + viewsLen + 6, base2StartY + 12);
|
||||
ctx.fillText('Views', 18 + timeLen + 6 + viewsLen + 6, base2StartY + 15);
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(16);
|
||||
ctx.fillText(formatNumberK(replies), 64, base2StartY + 145);
|
||||
ctx.fillText(formatNumberK(likes), 415, base2StartY + 145);
|
||||
ctx.fillText(formatNumberK(retweets + quotTweets), 242, base2StartY + 145);
|
||||
ctx.fillText(formatNumberK(bookmarks), 588, base2StartY + 145);
|
||||
ctx.fillText(formatNumberK(replies), 64, base2StartY + 148);
|
||||
ctx.fillText(formatNumberK(likes), 415, base2StartY + 148);
|
||||
ctx.fillText(formatNumberK(retweets + quotTweets), 242, base2StartY + 148);
|
||||
ctx.fillText(formatNumberK(bookmarks), 588, base2StartY + 148);
|
||||
let currentLen = 17;
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.font = this.client.fonts.get('Noto-Bold.ttf').toCanvasString(18);
|
||||
ctx.fillText(formatNumberK(retweets), currentLen, base2StartY + 75);
|
||||
ctx.fillText(formatNumberK(retweets), currentLen, base2StartY + 78);
|
||||
currentLen += ctx.measureText(formatNumberK(retweets)).width;
|
||||
currentLen += 5;
|
||||
ctx.fillStyle = '#71767b';
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(18);
|
||||
ctx.fillText('Reposts', currentLen, base2StartY + 75);
|
||||
ctx.fillText('Reposts', currentLen, base2StartY + 78);
|
||||
currentLen += ctx.measureText('Reposts').width;
|
||||
currentLen += 10;
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.font = this.client.fonts.get('Noto-Bold.ttf').toCanvasString(18);
|
||||
ctx.fillText(formatNumberK(quotTweets), currentLen, base2StartY + 75);
|
||||
ctx.fillText(formatNumberK(quotTweets), currentLen, base2StartY + 78);
|
||||
currentLen += ctx.measureText(formatNumberK(quotTweets)).width;
|
||||
currentLen += 5;
|
||||
ctx.fillStyle = '#71767b';
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(18);
|
||||
ctx.fillText('Quotes', currentLen, base2StartY + 75);
|
||||
ctx.fillText('Quotes', currentLen, base2StartY + 78);
|
||||
currentLen += ctx.measureText('Quotes').width;
|
||||
currentLen += 10;
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.font = this.client.fonts.get('Noto-Bold.ttf').toCanvasString(18);
|
||||
ctx.fillText(formatNumberK(likes), currentLen, base2StartY + 75);
|
||||
ctx.fillText(formatNumberK(likes), currentLen, base2StartY + 78);
|
||||
currentLen += ctx.measureText(formatNumberK(likes)).width;
|
||||
currentLen += 5;
|
||||
ctx.fillStyle = '#71767b';
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(18);
|
||||
ctx.fillText('Likes', currentLen, base2StartY + 75);
|
||||
ctx.fillText('Likes', currentLen, base2StartY + 78);
|
||||
currentLen += ctx.measureText('Likes').width;
|
||||
currentLen += 10;
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.font = this.client.fonts.get('Noto-Bold.ttf').toCanvasString(18);
|
||||
ctx.fillText(formatNumberK(bookmarks), currentLen, base2StartY + 75);
|
||||
ctx.fillText(formatNumberK(bookmarks), currentLen, base2StartY + 78);
|
||||
currentLen += ctx.measureText(formatNumberK(bookmarks)).width;
|
||||
currentLen += 5;
|
||||
ctx.fillStyle = '#71767b';
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(18);
|
||||
ctx.fillText('Bookmarks', currentLen, base2StartY + 75);
|
||||
ctx.fillText('Bookmarks', currentLen, base2StartY + 78);
|
||||
if (userData.avatarShape === 'Circle') {
|
||||
ctx.beginPath();
|
||||
ctx.arc(17 + 26, 84 + 26, 26, 0, Math.PI * 2);
|
||||
|
||||
Reference in New Issue
Block a user