ios - Swift 二次曲线路径不以曲线闭合
问题描述
我有一个 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)]
解决方案
推荐阅读
- flutter - FlutterLab:错误:此库已禁用空安全功能
- javascript - Cookies.get() 未定义
- mongodb - mongo $minKey 是什么意思?
- css - 我正在使用@media 查询,但我在不同屏幕上编写的代码不起作用
- javascript - 网站如何能够检测到使用 Chromium(如 Electron)的浏览器不是 Chrome 本身?
- python - 海龟图形到可执行文件
- neovim - 如何从子目录中提取 compile_commands.json?
- python-3.x - 如何让 flake8 捕捉不可调用的?
- macos - 卸载 Lua
- javascript - 如何在 React 中为 props 使用循环?