Skip to content

Instantly share code, notes, and snippets.

@alexnikol
Created Jun 16, 2020
Embed
What would you like to do?
Cuphead-EyesAndNoseShapes
private func getRightEyeShape() -> CAShapeLayer {
let rightEyeWrapPath = UIBezierPath()
rightEyeWrapPath.move(to: CGPoint(x: 392, y: 165))
rightEyeWrapPath.addCurve(to: CGPoint(x: 317, y: 175),
controlPoint1: CGPoint(x: 400, y: 200),
controlPoint2: CGPoint(x: 330, y: 230))
let eyePath = UIBezierPath()
eyePath.move(to: CGPoint(x: 345, y: 135))
eyePath.addQuadCurve(to: CGPoint(x: 350, y: 155),
controlPoint: CGPoint(x: 320, y: 150))
eyePath.addCurve(to: CGPoint(x: 315, y: 150),
controlPoint1: CGPoint(x: 355, y: 190),
controlPoint2: CGPoint(x: 315, y: 195))
eyePath.addCurve(to: CGPoint(x: 345, y: 135),
controlPoint1: CGPoint(x: 300, y: 100),
controlPoint2: CGPoint(x: 340, y: 100))
let rightEyeWrapShape = CAShapeLayer()
rightEyeWrapShape.path = rightEyeWrapPath.cgPath
rightEyeWrapShape.lineWidth = 5
rightEyeWrapShape.strokeColor = UIColor.black.cgColor
rightEyeWrapShape.fillColor = UIColor.clear.cgColor
let eyeShape = CAShapeLayer()
eyeShape.path = eyePath.cgPath
eyeShape.strokeColor = UIColor.black.cgColor
eyeShape.lineWidth = 1
eyeShape.fillColor = UIColor.black.cgColor
rightEyeWrapShape.addSublayer(eyeShape)
return rightEyeWrapShape
}
private func getLeftEyeShape() -> CAShapeLayer {
let leftEyeWrapPath = UIBezierPath()
leftEyeWrapPath.move(to: CGPoint(x: 135, y: 162))
leftEyeWrapPath.addCurve(to: CGPoint(x: 300, y: 105),
controlPoint1: CGPoint(x: 140, y: 280),
controlPoint2: CGPoint(x: 380, y: 280))
let eyePath = UIBezierPath()
eyePath.move(to: CGPoint(x: 233, y: 155))
eyePath.addQuadCurve(to: CGPoint(x: 242, y: 185),
controlPoint: CGPoint(x: 200, y: 180))
eyePath.addCurve(to: CGPoint(x: 190, y: 180),
controlPoint1: CGPoint(x: 250, y: 240),
controlPoint2: CGPoint(x: 215, y: 235))
eyePath.addCurve(to: CGPoint(x: 233, y: 155),
controlPoint1: CGPoint(x: 170, y: 120),
controlPoint2: CGPoint(x: 230, y: 130))
let leftEyeWrapShape = CAShapeLayer()
leftEyeWrapShape.path = leftEyeWrapPath.cgPath
leftEyeWrapShape.lineWidth = 5
leftEyeWrapShape.strokeColor = UIColor.black.cgColor
leftEyeWrapShape.fillColor = UIColor.clear.cgColor
let eyeShape = CAShapeLayer()
eyeShape.path = eyePath.cgPath
eyeShape.lineWidth = 1
eyeShape.strokeColor = UIColor.black.cgColor
eyeShape.fillColor = UIColor.black.withAlphaComponent(1).cgColor
leftEyeWrapShape.addSublayer(eyeShape)
return leftEyeWrapShape
}
private func getNoseShape() -> CAShapeLayer {
let nosePath = UIBezierPath(ovalIn: CGRect(x: 310, y: 180, width: 52, height: 30))
let noseShape = CAShapeLayer()
noseShape.path = nosePath.cgPath
noseShape.strokeColor = UIColor.black.cgColor
noseShape.lineWidth = 4
noseShape.fillColor = UIColor(named: "orangeColor")?.cgColor
return noseShape
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment