Skip to content

Instantly share code, notes, and snippets.

@zydeco
Created July 6, 2015 12:18
Show Gist options
  • Save zydeco/04dd647de4144172e636 to your computer and use it in GitHub Desktop.
Save zydeco/04dd647de4144172e636 to your computer and use it in GitHub Desktop.
iCloud UIBezierPath
let points = [
((-1, 0), (0,0), (13,25)),
((13, 22), (13, 24), (13, 23)),
((23, 12), (13, 17), (17, 12)),
((31, 16), (26, 12), (29, 14)),
((54, 0), (34, 7), (43, 0)),
((78, 24), (67, 0), (78, 11)),
((78, 27), (78, 25), (78, 26)),
((79, 27), (78, 27), (78, 27)),
((94, 42), (87, 27), (94, 33)),
((79, 57), (94, 50), (87, 57)),
((-2, 0), (0, 0), (55, 57)),
((-3, 0), (38, 57), (16, 57)),
((0, 41), (7, 57), (0, 49)),
((13, 25), (0, 33), (6, 26)),
((-3, 0), (47, 31), (47, 94)),
((-3, 0), (34, 71), (47, 94)),
((-3, 0), (60, 71), (47, 94))
]
let path = UIBezierPath()
for ((x1,y1),(x2,y2),(x3,y3)) in points {
switch x1 {
case -1: // move
path.moveToPoint(CGPoint(x: x3, y: y3))
case -2: // line
path.addLineToPoint(CGPoint(x: x3, y: y3))
case -3: // move+line
path.moveToPoint(CGPoint(x: x2, y: y2))
path.addLineToPoint(CGPoint(x: x3, y: y3))
default: // curve
path.addCurveToPoint(CGPoint(x:x1, y:y1), controlPoint1: CGPoint(x:x2, y:y2), controlPoint2: CGPoint(x:x3, y:y3))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment