avatar
Untitled

Guest 661 16th Dec, 2021

MARKUP 1.12 KB
                                           
                         func drawLine(coords: Array<Int>) {
        UIGraphicsBeginImageContext(canvas.bounds.size)
        canvas.draw(canvas.bounds)
        let ctx=UIGraphicsGetCurrentContext()
        ctx?.move(to: CGPoint(x: coords[0], y: coords[1]))
        ctx?.addLine(to: CGPoint(x: coords[2], y: coords[3]))
        ctx?.setLineWidth(3)
        ctx?.setStrokeColor(UIColor.black.cgColor)
        ctx?.strokePath()
        canvas.image=UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
    }
    func drawCircle(coords: Array<Int>) {
        UIGraphicsBeginImageContext(canvas.bounds.size)
        canvas.draw(canvas.bounds)
        let ctx=UIGraphicsGetCurrentContext()
        let rect = CGRect(x: coords[0], y: coords[1], width: coords[2], height: coords[3])
        ctx?.setStrokeColor(UIColor.black.cgColor)
        ctx?.setFillColor(UIColor.white.cgColor)
        ctx?.setLineWidth(3)
        ctx?.addEllipse(in: rect)
        ctx?.drawPath(using: .fillStroke)
        canvas.image=UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
    }
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data
Recent Pastes
Ta strona używa plików cookie w celu usprawnienia i ułatwienia dostępu do serwisu oraz prowadzenia danych statystycznych. Dalsze korzystanie z tej witryny oznacza akceptację tego stanu rzeczy.
Wykorzystywanie plików Cookie
Jak wyłączyć cookies?
ROZUMIEM