Shapes with Paths using SwiftUI Part4
A compendium of shapes using paths

In part 1, 2 and 3 of this series I covered isosceles polygons, the majority of triangles you could imagine, parallelograms and trapezoids and even random polygons; putting together routines to build them using methods based on circles. You can find the stories here. Shapes that you can mutate and animate to your hearts content in code.
Bon. We done pretty well considering almost everything is based on a simple circle. What now. Well looking thru my client requirements for shapes he wants a star. We could use an SF Symbol. The code to do so looks like this.
struct ContentView: View {
var body: some View {
Image(systemName: "star")
.font(.largeTitle)
.foregroundColor(Color.red)
}
}Which looks ok — but.

Wait, this is an article all about using the path to build things, besides which the brief said he needed a star with eight points and this one has five. Can we do this with our magic circle.
Of course you can, although you need at least two circles this time, not just one.

Yes, you counted correctly there are more than 8 points on this star when it finishes mutating, in fact with this method I can have a star with 360 points, which makes it look the sun, but no — that is a little too many, in this gif I limited the points to just 20.
So how do we this — basically the view uses two circles on which it calculates the number of points it needs [as in an 8 point star] in each circle. Skewing the placement of said points on the outer ring I then simply connect the dots.






