feat:数字学习卡

This commit is contained in:
R524809
2025-11-26 18:03:29 +08:00
parent 61e7781bf8
commit 698109e6f5
37 changed files with 872 additions and 158 deletions
+7 -1
View File
@@ -99,6 +99,7 @@ interface DrawMiniHeaderParams {
appName: string;
title: string;
};
canvasWidth?: number; // 逻辑像素宽度(可选,如果提供则使用,否则从 canvas.width 计算)
onHeaderDrawn?: (currentY: number) => void; // 绘制完成后的回调,用于设置 currentY 和绘制分割线
}
@@ -109,15 +110,20 @@ export function drawMiniHeader({
canvas,
ctx,
options,
canvasWidth,
onHeaderDrawn,
}: DrawMiniHeaderParams): void {
const { appName, title } = options;
const titleY = 120;
// 如果提供了逻辑宽度,使用它;否则使用 canvas.width(假设 ctx 未 scale
const centerX =
canvasWidth !== undefined ? canvasWidth / 2 : canvas.width / 2;
ctx.font = 'bold 64px "Microsoft Yahei"';
ctx.fillStyle = '#000';
ctx.textAlign = 'center';
ctx.fillText(appName + ' ' + title, canvas.width / 2, titleY);
ctx.fillText(appName + ' ' + title, centerX, titleY);
// 调用回调函数,让调用者设置 currentY 并绘制分割线
if (onHeaderDrawn) {