Display progression of lines drawn

Hello, I’ve been trying to get the program to display each line as its drawn. I’ve tried DispatchQueue and scheduledTimer with no avail. Any hints or suggestions?

mport UIKit

class Lines: UIView{
    
    var line=UIBezierPath()
    var num=800
    var factor=202
    
    var p=0
    var r=190.0
    var xn=0.0
    var yn=0.0
    var xt=0.0
    var yt=0.0
    
    
   
    
    func graph() {
        
        for i in 0..num{
                p=p-num
            }
            
            xn=r*cos(Double(i)*2*Double.pi/Double(num))+r
            yn=r-r*sin(Double(i)*2*Double.pi/Double(num))
            xt=r*cos(Double(p)*2*Double.pi/Double(num))+r
            yt=r-r*sin(Double(p)*2*Double.pi/Double(num))
            line.move(to:.init(x:xn,y:yn))
            line.addLine(to: .init(x:xt,y:yt))
            UIColor.blue.setStroke()
            line.lineWidth=0.002
            //self.stroke()
            line.stroke()
            //perform(#selector(self.stroke), with: nil, afterDelay: 0.0)
           
            //DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
                //self.stroke()
            
            
        }
        
    }
    
    
    @objc func stroke(){
        line.stroke()
    }

 override func draw(_ rect: CGRect){
       

       // plot()
        graph()
    }
}

Powered by WPeMatico

About

You may also like...

Comments are closed.