feat: 添加控笔页

This commit is contained in:
R524809
2026-05-28 16:46:30 +08:00
parent 824e83c887
commit 2f0c4ab591
21 changed files with 1406 additions and 169 deletions
+7 -2
View File
@@ -42,10 +42,10 @@ export function getScalingTransform(
}
/**
* SVG 路径解析与绘制(支持 M/L/Q/Z 命令)
* SVG 路径解析与绘制(支持 M/L/Q/C/Z 命令)
*/
export function drawSvgPath(ctx: RenderingContext, pathD: string) {
const commandRegex = /([MLQZ])([^MLQZ]*?)(?=[MLQZ]|$)/gi;
const commandRegex = /([MLQCZ])([^MLQCZ]*?)(?=[MLQCZ]|$)/gi;
const commands: Array<{ cmd: string; coords: string }> = [];
let match;
while ((match = commandRegex.exec(pathD)) !== null) {
@@ -69,6 +69,11 @@ export function drawSvgPath(ctx: RenderingContext, pathD: string) {
case 'Q':
if (v.length >= 4) ctx.quadraticCurveTo(v[0], v[1], v[2], v[3]);
break;
case 'C':
if (v.length >= 6) {
ctx.bezierCurveTo(v[0], v[1], v[2], v[3], v[4], v[5]);
}
break;
case 'Z':
ctx.closePath();
break;