我正在试着画一个相当基本的鸟的形状.我用圆圈画身体,我试着画上喙(以红色突出显示),如下面的参考图片所示.
图片参考:
struct Beak: Shape {
func path(in rect: CGRect) -> Path {
var path = Path()
path.move(to: CGPoint(x: rect.width/4, y: rect.height/2))
path.addLine(to: CGPoint(x: 0, y: rect.height/2))
// draw a line back to the circumference at a given angle
// & close it with an arc along the circumference of the Body circle
path.addLine(to: ??)
return path
}
}
struct BirdView: View {
var body: some View {
ZStack {
// MARK: Body
Circle()
.stroke(lineWidth: 10)
.frame(width: 150)
.overlay(alignment: .center) {
Circle()
.fill(.yellow)
}
// MARK: Beak
Beak()
.stroke(lineWidth: 5)
}
.frame(width: 300, height: 300)
.background(.orange)
}
}
我想要实现的是让喙也沿着身体圆周用一条弧线闭合,这样我就可以在以后通过旋转来模拟喙的打开/闭合.如有任何帮助,我们不胜感激.