Skip to content

Commit efe24ae

Browse files
committed
fix: 修复部分路径节点丢失的问题
1 parent 338857c commit efe24ae

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

src/model/Layer/ShapePath.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,16 @@ class ShapePath extends Base {
127127
: // 不然就是直的
128128
SketchFormat.CurveMode.Straight;
129129

130-
// 如果是闭合路径
131-
// 过滤最后一个点
132-
if (this.isClosed && index === this.points.length - 1) return;
130+
const firstPoint = this.points[0];
131+
if (
132+
// 如果是闭合路径
133+
this.isClosed &&
134+
// 且最后一个点和起点点一样
135+
index === this.points.length - 1 &&
136+
(point.x === firstPoint.x && point.y === firstPoint.y)
137+
)
138+
// 则过滤最后一个点
139+
return;
133140

134141
return {
135142
_class: 'curvePoint',

src/model/Layer/Svg.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ class Svg extends ShapeGroup {
5151
this.class = 'svg';
5252

5353
this.name = 'svg';
54-
5554
this.rawSVGString = path;
55+
5656
const { shapes, frame: innerFrame } = Svg.svgPathToShapeGroup(path);
57-
const boundingAspectRatio = width / height;
5857

58+
const boundingAspectRatio = width / height;
5959
const boxAspectRatio = innerFrame.width / height;
6060

6161
let scale = 1;

src/model/Layer/__test__/commonSvgData.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,12 @@ export const dropboxSvgPath = {
232232
{
233233
_class: 'curvePoint',
234234
cornerRadius: 0,
235-
curveFrom: '{0.59262569832402245, 0.5}',
235+
curveFrom: '{0.5926256983240225, 0.5}',
236236
curveMode: 1,
237-
curveTo: '{0.59262569832402245, 0.5}',
237+
curveTo: '{0.5926256983240225, 0.5}',
238238
hasCurveFrom: false,
239239
hasCurveTo: false,
240-
point: '{0.59262569832402245, 0.5}',
240+
point: '{0.5926256983240225, 0.5}',
241241
},
242242
],
243243
},
@@ -327,12 +327,12 @@ export const dropboxSvgPath = {
327327
{
328328
_class: 'curvePoint',
329329
cornerRadius: 0,
330-
curveFrom: '{0.85053987497632133, 0.48240100565681993}',
330+
curveFrom: '{0.8505398749763213, 0.4824010056568199}',
331331
curveMode: 1,
332-
curveTo: '{0.85053987497632133, 0.48240100565681993}',
332+
curveTo: '{0.8505398749763213, 0.4824010056568199}',
333333
hasCurveFrom: false,
334334
hasCurveTo: false,
335-
point: '{0.85053987497632133, 0.48240100565681993}',
335+
point: '{0.8505398749763213, 0.4824010056568199}',
336336
},
337337
],
338338
},
@@ -382,12 +382,12 @@ export const dropboxSvgPath = {
382382
{
383383
_class: 'curvePoint',
384384
cornerRadius: 0,
385-
curveFrom: '{1, 0.48316021403840109}',
385+
curveFrom: '{1, 0.4831602140384011}',
386386
curveMode: 1,
387-
curveTo: '{1, 0.48316021403840109}',
387+
curveTo: '{1, 0.4831602140384011}',
388388
hasCurveFrom: false,
389389
hasCurveTo: false,
390-
point: '{1, 0.48316021403840109}',
390+
point: '{1, 0.4831602140384011}',
391391
},
392392
],
393393
},

0 commit comments

Comments
 (0)