Cannot assign CGMutablePath to Path

19 Views Asked by At

This is probably a vey basic question, but I am getting an error below in the line "path = CGMutablePath()

struct Clock: Shape {
  //  func Clock(){
        var model: ClockTickerModel
        
        func path(in rect: CGRect) -> Path {
            var path = Path()
            path = CGMutablePath()
           // self.path = path
            let length = rect.width / 2
            let center = CGPoint(x: rect.midX, y: rect.midY)

            path.move(to: center)
            let hoursAngle = CGFloat.pi / 2 - .pi * 2 * model.angleMultiplier
            path.addLine(to: CGPoint(x: rect.midX + cos(hoursAngle) * length *                 model.tickerScale,
                                     y: rect.midY - sin(hoursAngle) * length *                 model.tickerScale))
            
            
            
            print("path")
            return path
        }
        
        
        
    }

I was hoping to add above code to below:

    let result =  Clock(model: .init (type: .minute, timeInterval: 0.5, tickScale:         0.4))

    Minline.path = result.path(in: <#T##CGRect#>)
    Minline.strokeColor = SKColor.red
    self.addChild(Minline)


    Any assistance would be appreciated

   Yours faithfully Confused..
0

There are 0 best solutions below