From fe7c30fab8cdfeb1a15cd1a4dda6aa4dd1d6f7da Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sat, 7 Nov 2020 14:38:00 -0500 Subject: [PATCH] Update Tweet Layout --- commands/edit-image/tweet.js | 35 +++++++++++++++++++++++++---------- package.json | 2 +- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/commands/edit-image/tweet.js b/commands/edit-image/tweet.js index 21a36d24..14bc0281 100644 --- a/commands/edit-image/tweet.js +++ b/commands/edit-image/tweet.js @@ -76,7 +76,8 @@ module.exports = class TweetCommand extends Command { canvas.height += linesLen; const likes = Math.floor(Math.random() * 100000) + 1; const retweets = Math.floor(Math.random() * 100000) + 1; - const replies = Math.floor(Math.random() * 100000) + 1; + const quoteTweets = Math.floor(Math.random() * 100000) + 1; + // const replies = Math.floor(Math.random() * 100000) + 1; ctx.fillStyle = '#15202b'; ctx.fillRect(0, base1.height, canvas.width, linesLen); ctx.drawImage(base1, 0, 0); @@ -108,21 +109,35 @@ module.exports = class TweetCommand extends Command { ctx.fillText('Twitter for Xiao', 31 + timeLen + 6, base2StartY + 16); ctx.fillStyle = '#8899a6'; ctx.font = '16px Noto'; - ctx.fillText(formatNumberK(replies), 87, base2StartY + 139); - ctx.fillText(formatNumberK(likes), 509, base2StartY + 139); - ctx.fillText(formatNumberK(retweets), 300, base2StartY + 139); + // ctx.fillText(formatNumberK(replies), 87, base2StartY + 139); + // ctx.fillText(formatNumberK(likes), 509, base2StartY + 139); + // ctx.fillText(formatNumberK(retweets), 300, base2StartY + 139); + let currentLen = 31; ctx.fillStyle = 'white'; ctx.font = 'normal bold 18px Noto'; - ctx.fillText(formatNumberK(retweets), 31, base2StartY + 77); - const retweetsLen = ctx.measureText(formatNumberK(retweets)).width; + ctx.fillText(formatNumberK(retweets), currentLen, base2StartY + 77); + currentLen += ctx.measureText(formatNumberK(retweets)).width; + currentLen += 5; ctx.fillStyle = '#8899a6'; ctx.font = '18px Noto'; - ctx.fillText('Retweets', 31 + retweetsLen + 5, base2StartY + 77); - const retweetsWordLen = ctx.measureText('Retweets').width; + ctx.fillText('Retweets', currentLen, base2StartY + 77); + currentLen += ctx.measureText('Retweets').width; + currentLen += 10; ctx.fillStyle = 'white'; ctx.font = 'normal bold 18px Noto'; - ctx.fillText(formatNumberK(likes), 31 + retweetsLen + 5 + retweetsWordLen + 10, base2StartY + 77); - const likesLen = ctx.measureText(formatNumberK(likes)).width; + ctx.fillText(formatNumberK(quoteTweets), currentLen, base2StartY + 77); + currentLen += ctx.measureText(formatNumberK(quoteTweets)).width; + currentLen += 5; + ctx.fillStyle = '#8899a6'; + ctx.font = '18px Noto'; + ctx.fillText('Quote Tweets', currentLen, base2StartY + 77); + currentLen += ctx.measureText('Quote Tweets').width; + currentLen += 10; + ctx.fillStyle = 'white'; + ctx.font = 'normal bold 18px Noto'; + ctx.fillText(formatNumberK(likes), currentLen, base2StartY + 77); + currentLen += ctx.measureText(formatNumberK(likes)).width; + currentLen += 5; ctx.fillStyle = '#8899a6'; ctx.font = '18px Noto'; ctx.fillText('Likes', 31 + retweetsLen + 5 + retweetsWordLen + 10 + likesLen + 5, base2StartY + 77); diff --git a/package.json b/package.json index d81cc34c..09c1568b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "119.39.1", + "version": "119.39.2", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {