Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Commit

Permalink
fix: text rendered
Browse files Browse the repository at this point in the history
  • Loading branch information
LewdHuTao committed Apr 21, 2024
1 parent 02d282a commit 42340da
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "songcard",
"version": "1.1.7",
"version": "1.1.8",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { classicCard } = require("./themes/classicCard");
const { simpleCard } = require("./themes/simpleCard");

module.exports = { classicCard, simpleCard }
module.exports = { classicCard, simpleCard };
13 changes: 6 additions & 7 deletions src/themes/classicCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ async function classicCard({
trackDuration,
trackTotalDuration,
}) {

const prettyMilliseconds = (await import("pretty-ms")).default;
const canvasWidth = 1200;
const canvasHeight = 400;
Expand Down Expand Up @@ -49,7 +48,7 @@ async function classicCard({
progressX,
0,
progressX + progressWidth,
0
0,
);

gradients.addColorStop(0, "white");
Expand All @@ -65,7 +64,7 @@ async function classicCard({
progressY,
progressWidth,
progressHeight,
borderRadius1
borderRadius1,
);
ctx.fill();

Expand Down Expand Up @@ -130,7 +129,7 @@ async function classicCard({
0,
0,
canvasWidth,
canvasHeight
canvasHeight,
);

ctx.save();
Expand All @@ -141,21 +140,21 @@ async function classicCard({
imageX + imageSize,
imageY,
imageX + imageSize,
imageY + borderRadius
imageY + borderRadius,
);
ctx.lineTo(imageX + imageSize, imageY + imageSize - borderRadius);
ctx.quadraticCurveTo(
imageX + imageSize,
imageY + imageSize,
imageX + imageSize - borderRadius,
imageY + imageSize
imageY + imageSize,
);
ctx.lineTo(imageX + borderRadius, imageY + imageSize);
ctx.quadraticCurveTo(
imageX,
imageY + imageSize,
imageX,
imageY + imageSize - borderRadius
imageY + imageSize - borderRadius,
);
ctx.lineTo(imageX, imageY + borderRadius);
ctx.quadraticCurveTo(imageX, imageY, imageX + borderRadius, imageY);
Expand Down
14 changes: 7 additions & 7 deletions src/themes/simpleCard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { createCanvas, loadImage } = require("canvas");
const { registerFont, createCanvas, loadImage } = require("canvas");
const Jimp = require("jimp");

async function simpleCard({ imageBg, imageText }) {
Expand Down Expand Up @@ -41,7 +41,7 @@ async function simpleCard({ imageBg, imageText }) {
0,
0,
canvasWidth,
canvasHeight
canvasHeight,
);

ctx.save();
Expand All @@ -52,21 +52,21 @@ async function simpleCard({ imageBg, imageText }) {
imageX + imageSize,
imageY,
imageX + imageSize,
imageY + borderRadius
imageY + borderRadius,
);
ctx.lineTo(imageX + imageSize, imageY + imageSize - borderRadius);
ctx.quadraticCurveTo(
imageX + imageSize,
imageY + imageSize,
imageX + imageSize - borderRadius,
imageY + imageSize
imageY + imageSize,
);
ctx.lineTo(imageX + borderRadius, imageY + imageSize);
ctx.quadraticCurveTo(
imageX,
imageY + imageSize,
imageX,
imageY + imageSize - borderRadius
imageY + imageSize - borderRadius,
);
ctx.lineTo(imageX, imageY + borderRadius);
ctx.quadraticCurveTo(imageX, imageY, imageX + borderRadius, imageY);
Expand Down Expand Up @@ -96,12 +96,12 @@ async function simpleCard({ imageBg, imageText }) {
truncatedText += "...";

ctx.fillStyle = "#fff";
ctx.font = "35px Sans";
ctx.font = `35px Sans`;
ctx.textAlign = "center";
ctx.fillText(truncatedText, textX, textY);
} else {
ctx.fillStyle = "#fff";
ctx.font = "35px Sans";
ctx.font = `35px Sans`;
ctx.textAlign = "center";
ctx.fillText(text, textX, textY);
}
Expand Down

0 comments on commit 42340da

Please sign in to comment.