Skip to content

Instantly share code, notes, and snippets.

@rockarts
Created October 5, 2018 04:01
Show Gist options
  • Save rockarts/61bfa88dfc5bdad21a825849e7821927 to your computer and use it in GitHub Desktop.
Save rockarts/61bfa88dfc5bdad21a825849e7821927 to your computer and use it in GitHub Desktop.
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()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment