func drawLine(x:Int, y:Int, width:Int, height:Int) { let leftToRight:Bool = Bool.random() let path = UIBezierPath() if(leftToRight) { path.move(to: CGPoint(x: x, y: y)) path.addLine(to: CGPoint(x: x + width, y: y + height)) } else { path.move(to: CGPoint(x: x + width, y: y)) path.addLine(to: CGPoint(x: x, y: y + height)) } path.close() UIColor.red.set() path.stroke() path.fill() }