SKShapeNode 笔划在使用 CGPath 绘制时显示间隙

SKShapeNode Strokes show gaps when drawn with CGPath

我正在尝试使用 CGPath 和 SKShapeNode 绘制形状。但是,无论我尝试使用 lineJoin 或 lineCap 组合,线条都有间隙。

import PlaygroundSupport
import SpriteKit

class GameScene: SKScene {

    override func didMove(to view: SKView) {
        super.didMove(to: view)
        let path = CGMutablePath()
        path.move(to: NSPoint(x: -66.585, y: 1.125))
        path.addCurve(to:  NSPoint(x: -60.585, y: -41.765), control1: NSPoint(x: -66.585, y: 1.125), control2: NSPoint(x: -65.835, y: -32.735))
        path.addCurve(to:  NSPoint(x: 66.585, y: -20.3150000000001), control1: NSPoint(x: -60.585, y: -41.765), control2: NSPoint(x: -3.39500000000001, y: -1.88499999999999))
        path.addCurve(to:  NSPoint(x: 56.545, y: 18.235), control1: NSPoint(x: 66.125, y: -7.09500000000003), control2: NSPoint(x: 62.695, y: 6.16499999999996))
        path.addCurve(to:  NSPoint(x: -66.585, y: 1.125), control1: NSPoint(x: 56.055, y: 19.1849999999999), control2: NSPoint(x: -15.415, y: 41.765))
        path.closeSubpath()
        let shapeNode = SKShapeNode(path: path)
        shapeNode.fillColor = .red
        shapeNode.lineWidth = 10
        shapeNode.lineJoin = .round
        shapeNode.strokeColor = .white
        addChild(shapeNode)
    }
}

let sceneView = SKView(frame: CGRect(x:0 , y:0, width: 640, height: 480))
if let scene = GameScene(fileNamed: "GameScene") {
    scene.scaleMode = .aspectFill
    sceneView.presentScene(scene)
}

PlaygroundSupport.PlaygroundPage.current.liveView = sceneView

我做错了什么?

我觉得这很奇怪:

    path.move(to: NSPoint(x: -66.585, y: 1.125))
    path.addCurve(to:  NSPoint(x: -60.585, y: -41.765), control1: NSPoint(x: -66.585, y: 1.125), control2: NSPoint(x: -65.835, y: -32.735))

您移动到 ​​(-66.58., 1.125)。然后添加一条曲线,其中第一个点是 (-60.585, -41.765),第一个控制点与您移动到的原始点相同。似乎这会导致一些奇怪的问题。我认为您希望移动的点成为曲线的第一个点,而不是它的控制点。