最重要的是我尝试对JSON进行编码/解码的bezier路径。底部是解码后的路径。
比较实际数据,所有点和控制点是相同的。例如,B的顶部曲线是:
path.move(to: CGPoint(x: 106, y: 35))
path.addCurve(to: CGPoint(x: 135, y: 47), controlPoint1: CGPoint(x: 106, y: 35), controlPoint2: CGPoint(x: 135, y: 31))
path.addCurve(to: CGPoint(x: 105.5, y: 59.5), controlPoint1: CGPoint(x: 135, y: 63), controlPoint2: CGPoint(x: 105.5, y: 59.5))
在JSON中是:
"elements" : [
{
"type" : "MoveTo",
"x" : 106,
"y" : 35
},
{
"x" : 135,
"y1" : 35,
"y" : 47,
"x1" : 106,
"y2" : 31,
"x2" : 135,
"type" : "CubicCurveTo"
},
{
"x" : 105.5,
"y1" : 63,
"y" : 59.5,
"x1" : 135,
"y2" : 59.5,
"x2" : 105.5,
"type" : "CubicCurveTo"
}
],
然而他们画的不同。
有人能发现底部路径中缺少什么吗?
答案 0 :(得分:1)
事实证明,当从JSON读入路径时,所有曲线都标记为kCGPathElementAddQuadCurveToPoint
而不是kCGPathElementAddCurveToPoint
。
(向库提交拉取请求)