I am working on the developer tutorial.
Drawing and Animation
Drawing Paths and Shapes
https://developer.apple.com/tutorials/swiftui/drawing-paths-and-shapes
Section 2 Step 9
How do you change the shape of the hexagon?
For example, what do I change in the code to add a side, making it a heptagon?
Drawing and Animation
Drawing Paths and Shapes
https://developer.apple.com/tutorials/swiftui/drawing-paths-and-shapes
Section 2 Step 9
How do you change the shape of the hexagon?
For example, what do I change in the code to add a side, making it a heptagon?
Code Block struct BadgeBackground: View { var body: some View { GeometryReader { geometry in Path { path in var width: CGFloat = min(geometry.size.width, geometry.size.height) let height = width let xScale: CGFloat = 0.832 let xOffset = (width * (1.0 - xScale)) / 2.0 width *= xScale path.move( to: CGPoint( x: xOffset + width * 0.95, y: height * (0.20 + HexagonParameters.adjustment))) HexagonParameters.points.forEach { path.addLine( to: .init( x: xOffset + width * $0.useWidth.0 * $0.xFactors.0, y: height * $0.useHeight.0 * $0.yFactors.0 ) ) path.addQuadCurve( to: .init( x: xOffset + width * $0.useWidth.1 * $0.xFactors.1, y: height * $0.useHeight.1 * $0.yFactors.1 ), control: .init( x: xOffset + width * $0.useWidth.2 * $0.xFactors.2, y: height * $0.useHeight.2 * $0.yFactors.2 ) ) } }