我有一个CGPoints数组,我正在根据该数组绘制一组曲线。我看到的是“形状”没有闭合。
let counterPath = UIBezierPath()
counterPath.move(to: counterPoints![0])
for (index, _) in counterPoints!.enumerated() {
if index % 2 == 0 {
if (index + 2) < counterPoints!.count {
counterPath.addQuadCurve(to: counterPoints![index + 2], controlPoint: counterPoints![index + 1])
} else {
//This should close the shape
counterPath.addQuadCurve(to: counterPoints![0], controlPoint: counterPoints![counterPoints!.count - 1])
}
}
}
counterPath.close()
每个点都在一个圆的圆周上。偶数点稍微“较高”(它们位于圆周上方),所有奇数点稍微“较低”(略低于圆周)。
正在发生的事情是未绘制最后一条曲线。我知道通常您只调用path.close(),但我需要使用四边形曲线将其关闭。
整体形状看起来像是由内而外的花朵。
示例如下:
这是CGPoints的数组:
[(288.079231262207, 109.933921813965), (244.400169372559, 102.082759857178), (227.010290145874, 61.2527008056641), (193.637225151062, 90.5069541931152), (150.87366104126, 78.6449432373047), (152.937526702881, 122.97599029541), (117.0, 149.01433874201), (152.945823669434, 175.041234970093), (150.89608001709, 219.372932434082), (193.656756401062, 207.497505187988), (227.038249969482, 236.740921020508), (244.415832519531, 195.904750823975), (288.091667175293, 188.040241241455), (267.0, 148.99356841296), (207.0, 149.0), (267.0, 148.999997138029)]