细节调整
This commit is contained in:
25
src/util.js
25
src/util.js
@@ -60,16 +60,16 @@ export function renderText(ctx, text, size, color, x, y, textAlign = "left") {
|
||||
}
|
||||
|
||||
export function renderRankTitle(ctx, text) {
|
||||
const fontSize = 10;
|
||||
const fontSize = 8;
|
||||
const textWidth = ctx.measureText(text).width;
|
||||
const padding = 8; // 文字与背景边缘的间距
|
||||
const radius = 10; // 圆角半径
|
||||
const textX = 85;
|
||||
const textY = 55;
|
||||
const x = textX - padding - 15; // 文字 x 坐标减去内边距
|
||||
const textY = 52;
|
||||
const x = textX - padding - 12; // 文字 x 坐标减去内边距
|
||||
const y = textY - fontSize - padding / 2 + 1; // 文字 y 坐标减去字体大小和内边距
|
||||
const width = textWidth + padding * 2 - 19; // 背景宽度
|
||||
const height = fontSize + padding + 1; // 背景高度
|
||||
const width = textWidth + padding * 2 - 24; // 背景宽度
|
||||
const height = fontSize + padding; // 背景高度
|
||||
|
||||
// 开始绘制圆角矩形
|
||||
ctx.beginPath();
|
||||
@@ -136,9 +136,9 @@ export function generateCanvasImage(canvasId, type, user, data) {
|
||||
const width = 303;
|
||||
const height = 535;
|
||||
ctx.drawImage("../static/share-bg.png", 0, 0, 302, 534);
|
||||
drawRoundImage(ctx, user.avatar, 20, 20, 35, 35, 20);
|
||||
ctx.drawImage("../static/avatar-frame.png", 15, 15, 45, 45);
|
||||
renderText(ctx, user.nickName, 14, "#fff", 77, 35, "center");
|
||||
drawRoundImage(ctx, user.avatar, 17, 20, 37, 37, 20);
|
||||
ctx.drawImage("../static/avatar-frame.png", 12, 15, 47, 47);
|
||||
renderText(ctx, user.nickName, 14, "#fff", 80, 32, "center");
|
||||
renderRankTitle(ctx, user.lvlName, "center");
|
||||
|
||||
let titleImage = "../static/first-try-title.png";
|
||||
@@ -155,7 +155,14 @@ export function generateCanvasImage(canvasId, type, user, data) {
|
||||
}
|
||||
ctx.drawImage(titleImage, (width - 160) / 2, 160, 160, 40);
|
||||
const subTitleWidth = ctx.measureText(subTitle).width;
|
||||
renderText(ctx, subTitle, 18, "#fff", width / 2 - subTitleWidth + 10, 220);
|
||||
renderText(
|
||||
ctx,
|
||||
subTitle,
|
||||
18,
|
||||
"#fff",
|
||||
width / 2 - subTitleWidth - (type > 1 ? 15 : 8),
|
||||
220
|
||||
);
|
||||
renderText(ctx, "共", 16, "#fff", 124, 300);
|
||||
const totalRing = data.arrows.reduce((last, next) => last + next.ring, 0);
|
||||
renderText(ctx, totalRing, 16, "#fed847", totalRing < 100 ? 144 : 142, 300);
|
||||
|
||||
Reference in New Issue
Block a user