Skip to content

Commit 8a847c2

Browse files
author
zc310.tech
committed
修复 未支持Path S 标记
1 parent 6c12bb7 commit 8a847c2

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

internal/models/path.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ import (
99
)
1010

1111
// CommandType 定义路径命令类型
12-
// M: 移动到 (Move to)
13-
// L: 直线到 (Line to)
14-
// B: 三次贝塞尔曲线 (Cubic Bezier curve)
15-
// Q: 二次贝塞尔曲线 (Quadratic Bezier curve)
16-
// A: 椭圆弧 (Elliptical arc)
17-
// C: 闭合路径 (Close path)
12+
// S: SubPath起点 (Start point of SubPath) - 定义子路径的起始点坐标(x,y)
13+
// M: 移动到 (Move to) - 移动画笔到指定点,不绘制线条
14+
// L: 直线到 (Line to) - 从当前点到指定点绘制直线
15+
// B: 三次贝塞尔曲线 (Cubic Bezier curve) - 需要两个控制点和一个终点的曲线
16+
// Q: 二次贝塞尔曲线 (Quadratic Bezier curve) - 需要一个控制点和一个终点的曲线
17+
// A: 椭圆弧 (Elliptical arc) - 绘制椭圆弧线
18+
// C: 闭合路径 (Close path) - 从当前点绘制直线回到子路径起点
1819
type CommandType string
1920

2021
const (
22+
Start CommandType = "S" // 子路径起点
2123
MoveTo CommandType = "M" // 移动到命令
2224
LineTo CommandType = "L" // 直线命令
2325
CubicBezier CommandType = "B" // 三次贝塞尔曲线命令
@@ -95,7 +97,7 @@ func (p *SVGPath) parsePathData(data string) (SVGPath, error) {
9597
token := tokens[index]
9698

9799
switch token {
98-
case "M":
100+
case "M", "S":
99101
cmd, nextIdx, err := p.parseMoveCommand(tokens, index)
100102
if err != nil {
101103
return nil, err

internal/render/document_path.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (p *Document) newPath(cp *models.CtPath, transform func(pt models.StPos) (f
8585
pa := &canvas.Path{}
8686
for _, cmd := range cp.AbbreviatedData {
8787
switch cmd.Type {
88-
case models.MoveTo, "S":
88+
case models.MoveTo, models.Start:
8989
x, y := transform(cmd.Points[0])
9090
pa.MoveTo(x, y)
9191

0 commit comments

Comments
 (0)